后退箭头的Android颜色,菜单文本颜色和组件默认颜色 [英] Android color of back arrow, menu text color and component default colors
问题描述
我一直在努力用样式来更改某些组件的颜色,但是似乎每个属性都会影响另一个属性.这是我正在使用的样式
I've been struggling to change the colors of some components with styles but seems every property affects another. Here's the styles that I'm using
Color.xml
Color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">@color/blue</color>
<color name="colorPrimaryDark">@color/blue</color>
<color name="colorAccent">@color/blue</color>
<color name="blue">#032C60</color>
<color name="grey">#e1e0e0</color>
</resources>
styles.xml
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:textColorPrimary">@color/colorPrimary</item>
<item name="android:textColorSecondary">@color/colorPrimary</item>
<item name="android:itemTextAppearance">@style/menuItemColor</item>
<item name="colorControlNormal">@android:color/white</item>
</style>
<style name="menuItemColor">
<item name="android:textColor">@color/blue</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<!--<style name="ToolbarTheme">-->
<!--<item name="android:actionMenuTextColor">@color/blue
</resources>
styles.xml v21
styles.xml v21
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/colorPrimary</item>
<item name="android:textColorPrimary">@color/colorPrimary</item>
<item name="android:textColorSecondary">@color/colorPrimary</item>
<item name="android:itemTextAppearance">@style/menuItemColor</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
我有一个蓝色的工具栏,并用
I have a blue toolbar and made the arrow, ... menu action white, and toolbar title white with
app:titleTextColor="@android:color/white"
唯一的问题是未聚焦的edittext下划线和未选中的复选框边框颜色都受白色控件颜色的影响,白色控件背景是白色的,因此它们也必须是蓝色的.但是,当我更改样式时,后退箭头和...也会受到影响.任何帮助表示赞赏.
The only problem remains is that unfocused edittext underline and unchecked checkbox border color both is effected by control color white, which is on a white background so they need to be blue as well. But when I change the styles, back arrow and ... is also affected. Any helps are appreciated.
推荐答案
在两个style.xml
文件中为工具栏添加样式:
Add style for your Toolbar in both style.xml
files:
<style name="AppTheme.Toolbar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">?android:attr/colorPrimary</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
将样式设置为工具栏布局:
Set style to your Toolbar layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
style="@style/AppTheme.Toolbar"/>
这将为您提供以您的原色"着色的工具栏,并且所有元素都将变亮.
This will give you Toolbar that coloured in your Primary Colour and all elements will become light.
然后删除app:titleTextColor="@android:color/white"
以恢复复选框和其他元素的颜色.
Then delete app:titleTextColor="@android:color/white"
to restore checkbox and other elements colour.
这篇关于后退箭头的Android颜色,菜单文本颜色和组件默认颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!