我正在设置操作栏的后退箭头并更改其颜色,如下所示:
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
,但颜色正在改变,但问题是它有点透明。
这里有两张图片可以阐明我的观点。
它是这样的:
虽然颜色应该喜欢这个其他组件:
我尝试了 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/