我使用的是android.support.v7.widget.Toolbar,并从this post那里学到了如何将汉堡图标的颜色更改为白色,但在调用
setDisplayHomeAsUpEnabled(true);
怎样才能把箭头也变成白色呢?
下面是我调用setDisplayHomeAsUpEnabled()时工具栏的样子:
...and这里是我的styles.xml文件的相关部分:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">#194C5F</item>
<item name="colorAccent">@color/accent</item>
<item name="drawerArrowStyle">@style/WhiteDrawerIconStyle</item>
</style>
<style name="WhiteDrawerIconStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
发布于 2015-02-20 23:00:22
我通过编辑styles.xml解决了这个问题:
<style name="ToolbarColoredBackArrow" parent="AppTheme">
<item name="android:textColorSecondary">INSERT_COLOR_HERE</item>
</style>
引用活动中工具栏定义中的样式的...then:
<LinearLayout
android:id="@+id/main_parent_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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"
app:theme="@style/ToolbarColoredBackArrow"
app:popupTheme="@style/AppTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
发布于 2015-03-29 00:25:47
这就是你要找的东西。但是这也改变了radioButton的颜色等,所以你可能想要为它使用一个主题。
<item name="colorControlNormal">@color/colorControlNormal</item>
发布于 2015-07-25 18:46:30
这个答案可能太晚了,但我是这样做的。设置工具栏的样式将会起到这个作用。使用以下代码创建toolbar.xml。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_alignParentTop="true"
android:layout_gravity="bottom"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
在styles.xml中
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!--
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
最后,在布局中包含工具栏
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
https://stackoverflow.com/questions/28620883
复制相似问题