我想更改工具栏中的文字颜色和导航图标颜色
更改操作项的文本颜色" 13311"
还有抽屉图标。
风格 //活动主题
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="switchStyle">@style/Switch</item>
</style>
//theme for switch widget
<style name="Switch" parent="Widget.AppCompat.CompoundButton.Switch">
<item name="android:thumb">@drawable/switch_selector</item>
<item name="showText">false</item>
</style>
//toolbar theme
<style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar">
<item name="android:gravity">center_vertical</item>
<!--<item name="popupTheme">@style/PopupMenuStyle</item>-->
<item name="actionButtonStyle">@style/MyActionButtonStyle</item>
</style>
//overflow menu theme
<style name="PopupMenuStyle" parent="Base.ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">@color/black</item>
<item name="android:gravity">left|center</item>
<item name="android:background">@color/white</item>
</style>
//action button theme
<style name="MyActionButtonStyle" parent="AppBaseTheme">
<item name="android:minWidth">0dip</item>
<item name="android:textSize">14sp</item>
<item name="android:paddingLeft">0dip</item>
<item name="android:paddingRight">0dip</item>
<item name="android:actionMenuTextColor">@color/white</item>
</style>
答案 0 :(得分:4)
<style name="MyDarkToolbarStyle" parent="ThemeOverlay.AppCompat.ActionBar">
<!-- text color for action menu icons -->
<item name="android:textColorSecondary">#fff</item>
<!-- overflow menu icon color -->
<item name="actionMenuTextColor">#fff</item>
</style>
修改强> 要更改导航抽屉颜色,请使用
<style name="DrawerStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/drawer_color</item>
</style>
答案 1 :(得分:1)
将父主题更改为darkactionbar 当操作栏处于黑暗状态时,您将获得图标和文本为白色,当它处于光线状态时,您将使它们变黑。 那就是
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
答案 2 :(得分:0)
要更改箭头颜色,我使用 colorControlNormal 来自 AppTheme 和 AppTheme.ActionBarTheme
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:windowTranslucentStatus" tools:targetApi="21">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBar">false</item>
<!-- Toolbar Theme / Apply white arrow -->
<item name="colorControlNormal">@android:color/white</item>
<item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item>
<item name="android:itemTextAppearance">@style/ToolbarTextAppearance</item>
<!-- Material Theme -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/accent_color</item>
<item name="android:statusBarColor" tools:targetApi="21">@color/statusBarColor</item>
<item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
</style>
<style name="AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- White arrow -->
<item name="colorControlNormal">@android:color/white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/drawerArrowColor</item>
</style>
<style name="ToolbarTextAppearance">
<item name="android:textColor">@android:color/white</item>
</style>