item selected color in android BottomNavigationView
create a color directory in res folder and create your xml file for customize your bottom navigation items:
res/color/bottom_nav_color.xml:
<?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/your_color" />
<item android:state_checked="false" android:color="@color/your_color"/>
</selector>
and in your BottomNavigationView
set app:itemTextColor
and app:itemIconTint
values to @color/bottom_nav_color
<android.support.design.widget.BottomNavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/actionBarColor"
app:menu="@menu/my_navigation_items"
app:itemTextColor="@color/bottom_nav_color"
app:itemIconTint="@color/bottom_nav_color"/>
- Make a xml file in the drawable folder with the name of
navigation_view_colored.xml
and put this inside:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:color="@color/gray" />
<item android:state_checked="true" android:color="@color/blue" />
</selector>
- Add the xml you created to
app:itemIconTint
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bottom_navigation"
android:layout_alignParentBottom="true"
app:itemIconTint="@drawable/navigation_view_colored"
app:itemTextColor="@color/blue"
app:menu="@menu/bottom_navigation"
android:background="?android:attr/windowBackground"/>
here is simple solution to your question
<android.support.design.widget.TabLayout
....
app:tabBackground="@drawable/tab_color_selector"
...
/>
the selector res/drawable/tab_color_selector.xml
:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/tab_background_selected" android:state_selected="true"/>
<item android:drawable="@color/tab_background_unselected" android:state_checked="false"/>
</selector>
update tab item selector color what your required to.