【发布时间】:2015-01-03 11:46:14
【问题描述】:
我已将我的 SDK 更新到 API 21,现在备份/后退图标是一个指向左侧的黑色箭头。
我希望它是灰色的。我该怎么做?
例如,在 Play 商店中,箭头是白色的。
我这样做是为了设置一些样式。我已将@drawable/abc_ic_ab_back_mtrl_am_alpha 用于homeAsUpIndicator。该drawable是透明的(只有alpha),但箭头显示为黑色。我想知道我是否可以像在DrawerArrowStyle 中那样设置颜色。或者,如果唯一的解决方案是创建我的@drawable/grey_arrow 并将其用于homeAsUpIndicator。
<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
<item name="android:homeAsUpIndicator" tools:ignore="NewApi">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
</style>
<!-- ActionBar style -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:background">@color/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">@color/actionbar_background</item>
</style>
<!-- Style for the navigation drawer icon -->
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@color/actionbar_text</item>
</style>
到目前为止,我的解决方案是使用看起来是白色的@drawable/abc_ic_ab_back_mtrl_am_alpha,并使用照片编辑器将其绘制成我想要的颜色。它可以工作,虽然我更喜欢使用 @color/actionbar_text,就像在 DrawerArrowStyle 中一样。
【问题讨论】:
-
到目前为止,基于 XML 的答案都没有为我解决此问题,但我已成功使用您的
homeAsUpIndicator/@drawable/abc_ic_ab_back_mtrl_am_alpha代码将后退箭头设为白色。我更喜欢这个而不是侵入 Java。 -
旧但仍然。您使用的是 ActionBar 还是新的 Toolbar?
-
默认的应该有点灰色,通过在 Toolbar XML 标签中使用 android:theme="@style/Widget.AppCompat.Light.ActionBar"。它的颜色是#737373
-
检查我的答案 - 它超级简单,没有副作用。
标签: java android user-interface colors android-styles