I add a BottomNavigationView to the project and would like to have a different text color (and icon hue) for the selected tab (to achieve the effect of the BottomNavigationView tabs). Using a different color with android:state_selected="true" in the color selector resource file does not seem to work. I also tried to have additional element entries with android:state_focused="true" or android:state_enabled="true" , unfortunately android:state_enabled="true" . Also tried to set the state_selected attribute to false (explicitly) for the default color ( state_selected ), but to no avail.
Here is how I can add a view to my layout:
<android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" app:itemBackground="@color/silver" app:itemIconTint="@color/bnv_tab_item_foreground" app:itemTextColor="@color/bnv_tab_item_foreground" app:menu="@menu/bottom_nav_bar_menu" />
Here is my color selector ( bnv_tab_item_foreground.xml ):
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@android:color/darker_gray" /> <item android:state_selected="true" android:color="@android:color/holo_blue_dark" /> </selector>
And my menu resource ( bottom_nav_bar_menu.xml ):
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/action_home" android:icon="@drawable/ic_local_taxi_black_24dp" android:title="@string/home" /> <item android:id="@+id/action_rides" android:icon="@drawable/ic_local_airport_black_24dp" android:title="@string/rides"/> <item android:id="@+id/action_cafes" android:icon="@drawable/ic_local_cafe_black_24dp" android:title="@string/cafes"/> <item android:id="@+id/action_hotels" android:icon="@drawable/ic_local_hotel_black_24dp" android:title="@string/hotels"/> </menu>
I would be grateful for any help.
android material-design navigationbar
Javad Sadeqzadeh Oct 30 '16 at 2:00 2016-10-30 02:00
source share