Laura
Laura

Reputation: 432

How to customize Bottom Navigation View?

I'm using Bottom Navigation View in my application. Everything is working fine but I need to add selected purple line when one of the items is selected. How can I achieve this?enter image description here

Upvotes: 0

Views: 188

Answers (1)

hemen
hemen

Reputation: 1500

It's Easy, Create a color folder in resource and paste the below xml nav_item_color_state.xml (I am using blue color, modify as per your own)

   <?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>

and then "itemIconTint" and "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" />

Upvotes: 1

Related Questions