【发布时间】:2017-07-09 02:24:23
【问题描述】:
我想将工具栏中的汉堡包/后退箭头的颜色从 colorPrimaryDark 更改为白色。
在我的 style.xml 文件中,我有 2 个主题:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="colorButtonNormal">@color/white</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<!-- Toolbar theme. -->
<style name="toolbar" parent="AppTheme">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="android:textColor">@color/black</item>
<item name="android:textColorSecondary">@android:color/white</item>
</style>
这是我的工具栏:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/toolbar">
</android.support.v7.widget.Toolbar>
我尝试了几种方法,唯一可行的方法是将 <item name="android:textColorSecondary">@android:color/white</item> 从工具栏主题移动到基本应用程序主题。
这对我来说不好,因为在基本主题中将 textColorSecondary 设置为白色也会改变其他组件的颜色。
我只想为我的工具栏设置它。但即使我有<item name="android:textColorSecondary">@android:color/white</item> 并使用"android:theme="@style/toolbar" 将我的工具栏样式设置为toolbar.xml,它也不起作用
奇怪的是其他的主题颜色都被正确应用了。
我哪里错了?
【问题讨论】:
-
你试过this吗?
-
是的,但它只改变了汉堡图标的颜色而不是两者,为什么?
标签: android material-design android-toolbar navigation-drawer