答案 0 :(得分:1)
很简单, 在资源中创建一个颜色文件夹并粘贴以下xml nav_item_color_state.xml(我使用的是蓝色,请根据您的要求进行修改)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FF0096D6" android:state_checked="true" />
<item android:color="#FF666666" />
</selector>
然后是“ itemIconTint”和“ itemTextColor”
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="#fff"
app:itemIconTint="@color/nav_item_color_state"
app:itemTextColor="@color/nav_item_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />