Search code examples
androidandroid-layoutandroid-bottomnavandroid-bottom-nav-view

Change background colour of area behind selected item in Android Bottom Navigation Bar


Is it possible to change the background colour of the particular portion of the bar behind the selected item of the bottom navigation bar or any third party libraries that support this?

Also is it possible to add a highlighted bar along the bottom of the selected item like the image below?

See below screenshot:

Bottom Navigation Bar Sample


Solution

  • You can use the app:itemBackground attribute of BottomNavigationView to do this. The "selected" view is actually checked, so keep that in mind when you're creating your state list.

    Something like this should work:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@color/blue" android:state_checked="true"/>
        <item android:drawable="@color/gray"/>
    </selector>