android - 更改操作栏提供的默认后退箭头的颜色

标签 android colors android-actionbar

我正在设置操作栏的后退箭头并更改其颜色,如下所示:

final Drawable upArrow = getResources().getDrawable(R.drawable.ic_action_navigation_arrow_back);
upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);

如您所见,我正在更改此行中箭头的颜色,因为默认返回的箭头是灰色的,此处:

upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);

虽然我提供的颜色 white 具有以下十六进制代码 #FFFFFFFF,但颜色正在改变,但问题是它有点透明。

这里有两张图片可以阐明我的观点。

它是这样的:

This is how it looks

虽然颜色应该喜欢这个其他组件:

enter image description here

我尝试了 PorterDuff.Mode.XXXX 下的所有选项,但都没有用。

最佳答案

请更改您的 style.xml

    <style name="MyCustomTheme" parent="Custom.Base">

   </style>

<style name="Custom.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/white</item>
</style>

关于android - 更改操作栏提供的默认后退箭头的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40630881/

相关文章:

java - 附加到谷歌驱动器文件,无需用户选择

android - 向 Firebase DB 添加新字段时的向后兼容性

java - 如何使布局占屏幕宽度的 80%?

java - 在构建路径中包含其他项目时出现 NoClassDefFounderror

macos - OS X 终端颜色

Android:加载应用程序时填充默认操作栏

java - 将 RGBA 值转换为十六进制颜色代码

java - 非常基本的 GObject/GOval For 循环

android - 从 viewpager 向后滑动会导致应用程序崩溃

android - 设置即将与操作栏支持库一起溢出