我想自定义工具栏的颜色,但是工具栏的自定义样式更改不起作用。
我使用了appcompat 'com.android.support:appcompat-v7:22.1.1'
在工具栏中,我设置了:
<android.support.v7.widget.Toolbar
android:theme="@style/StyleTest"
(我也尝试使用 app:theme 但是这些都没有生效)
这是我的工具栏样式:
<style name="StyleTest" parent="Theme.AppCompat.NoActionBar">
<item name="android:textColorPrimary">@color/green</item>
<item name="actionMenuTextColor">@color/yellow</item>
<item name="android:textColorSecondary">@color/red</item>
</style>
这种样式不起作用。 但是当我更改应用程序样式项时,工具栏中的样式也会更改(而工具栏具有自己的android:theme值)。 例如,当我更改应用程序样式项“textColorSecondary”时,工具栏中的返回箭头也会更改,但我想在工具栏样式和应用程序样式中使用不同的颜色。 这是应用程序样式:
<!-- Application theme. -->
<style name="AppTheme" parent="MaterialDrawerTheme.Light.DarkToolbar">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<!-- colorPrimary is a toolbar background -->
<item name="colorPrimary">#5EB1F7</item>
<!-- colorAccent color of pressed widget -->
<item name="colorAccent">@color/blue_dark</item>
<item name="actionModeBackground">@color/black_half_transparent</item>
<item name="android:textColor">@color/black</item>
<!-- textColorPrimary is a color of the title for Toolbar -->
<item name="android:textColorPrimary">@color/white</item>
<!-- colorPrimaryDark is a color for lollipop system bar -->
<item name="colorPrimaryDark">@color/material_drawer_background</item>
<!-- android:textColorSecondary is the color of the back arrow and menu
overflow icon (three vertical dots) -->
<item name="android:textColorSecondary">@color/blue</item>
</style>
当我更改应用程序样式项,例如colorPrimary、textColorPrimary或textColorSecondary时,这会应用于工具栏,但工具栏自身的样式被忽略了。 我该如何将自定义样式应用于工具栏?