6

I am trying to create Bottom navigation view in android without a title, but I'm unable to hide the title. Also, I need to active and inactive icon colour for Bottom navigation view.

Expected design enter image description here

Current design enter image description here

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottomNavigationView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="start"
    android:layout_alignParentBottom="true"
    android:background="@color/bottom_nav_colour"
    app:itemTextColor="@color/black"
    app:itemIconTint="@color/black"
    design:menu="@menu/bottom_navigation" />

bottom_navigation.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/menu_home"
        android:title="@string/menu_home"
        android:icon="@drawable/home" />

    <item
        android:id="@+id/menu_search"
        android:title="@string/menu_search"
        android:icon="@drawable/search"/>

    <item
        android:id="@+id/menu_add"
        android:title="@string/menu_add"
        android:icon="@drawable/add"/>

    <item
        android:id="@+id/menu_wishlist"
        android:title="@string/menu_wishlist"
        android:icon="@drawable/wishlist"/>

    <item
        android:id="@+id/menu_account"
        android:title="@string/menu_account"
        android:icon="@drawable/account" />
</menu>
5
  • 1
    I think this link be helepful : stackoverflow.com/questions/40183239/… Commented Jan 28, 2017 at 4:40
  • @Kintanpatel The above link did not work out Commented Jan 28, 2017 at 11:51
  • Try to add this line in all your menu file android:title="" just make a blank title Commented Jan 29, 2017 at 8:33
  • This will keep blank space at the bottom. And the icon will not appear in center
    – AkshayT
    Commented Jun 27, 2017 at 9:46
  • check out my answer below view solution
    – Rajesh.k
    Commented Nov 17, 2017 at 8:52

2 Answers 2

3

In the latest support library for BottomNavigationView you can use labelVisibility

-1

You can create selector for icons.

selector_home_icon.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="drawable/home" android:state_selected="true"/>
    <item android:drawable="drawable/home_disabled"/>
</selector>

Set this selector as icon drawable

bottom_navigation.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/menu_home"
        android:title="@string/menu_home"
        android:icon="@drawable/selector_home_icon" />

     .......

</menu>
2
  • use state_checked="true" instead of state_selected
    – Anksss
    Commented May 30, 2018 at 18:59
  • He's using Bottom Navigation not TabLayout!
    – Wale
    Commented Sep 24, 2018 at 21:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.