【发布时间】:2015-07-28 22:49:23
【问题描述】:
我想自定义工具栏的颜色,但更改工具栏的自定义样式不起作用。
我使用 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 这应用于工具栏,但工具栏自己的样式被忽略。 如何将自定义样式应用到工具栏?
【问题讨论】:
-
我有同样的问题,但 TabLayout。
标签: android styles toolbar material-design