[英]How to change the bottom on screen soft navigation background and icon color in android?
[英]Bottom Navigation Icon color change
当我尝试使用黑色背景更改底部导航图标颜色时,我使用的是底部导航,它不会改变颜色。
bottomNavigation.setAccentColor(Color.parseColor("#FFE4770A"));
bottomNavigation.setInactiveColor(Color.WHITE);
bottomNavigation.setBackgroundColor(Color.BLACK);
但是当我用背景尝试它时,它会改变图标颜色。
bottomNavigation.setAccentColor(Color.parseColor("#FFE4770A"));
bottomNavigation.setInactiveColor(Color.WHITE);
如何修复它? 它用彩色背景改变图标颜色。
我有另一个解决方案,如果你想尝试使用 XML,
app:itemBackground="@color/white" --> 这可用于底部栏颜色 app:itemIconTint="@color/blue" --> 这可用于更改图标颜色 app:itemTextColor="@color/ blue" --> 这可用于更改图标底部文本颜色
XML源代码如下所示
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
app:itemBackground="@color/white"
app:itemIconTint="@color/blue"
app:itemTextColor="@color/blue"
app:menu="@menu/navigation" />
根据ahbottomnavigation repo 的文档, setBackgroundColor()
将覆盖图标的强调色。
将setBackgroundColor()
替换为setDefaultBackgroundColor()
:
bottomNavigation.setDefaultBackgroundColor(Color.BLACK);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.