Skip to content
Advertisement

How to set text color of bottom navigation item selection and unselection?

I was trying to set the following attribute of BottomNavigationView widget

app:itemTextColor="@color/text_color"

But this sets the text color of active and inactive item both. I want to have different text color on active and inactive item of BottomNavigationView.

Advertisement

Answer

First, you have to make a selectable color in res>color>selectable_color

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:color="@color/selected_text_color" />
    <item android:state_checked="false" android:color="@color/unselected_text_color"/>
</selector>

Then you have to set this selectable color as itemTextColor in BottomNavigationView widget

app:itemTextColor="@color/selectable_text_color"
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement