Nouman
Nouman

Reputation: 132

Always show icon with label in BottomNavigationView for more then 3 items

I am using 5 items in BottomNavigationView but it only shows the label text for the active one. It works fine for the 3 item but not for more than 3 items.

Current view

Current view

All i want is like this:

All i want is like this:

activity_main.xml

<android.support.design.widget.BottomNavigationView
    android:id="@+id/main_bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:background="@color/colorPrimary"
    app:itemIconTint="@drawable/bottom_nav_colors"
    app:itemTextColor="@drawable/bottom_nav_colors"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/navigation"
    android:layout_alignParentLeft="true" />

navigation.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/bnavigation_allGames"
        android:icon="@drawable/football_footer"
        android:checkable="true"
        android:title="@string/bmenu_text_all_games" />

    <item
        android:id="@+id/bnavigation_favourites"
        android:icon="@drawable/favourite_footer"
        android:checkable="true"
        android:title="@string/bmenu_text_favourites" />

    <item
        android:id="@+id/bnavigation_favourites_A"
        android:icon="@drawable/favourite_footer"
        android:checkable="true"
        android:title="My Teams" />

    <item
        android:id="@+id/bnavigation_favourites_b"
        android:icon="@drawable/favourite_footer"
        android:checkable="true"
        android:title="My Leagues" />

    <item
        android:id="@+id/bnavigation_fixtures_standings"
        android:icon="@drawable/fixtures_footer"
        android:checkable="true"
        android:title="@string/bmenu_text_fixtures_standings" />

</menu>

I have tried multiple solutions like

bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED)

and also some other but they are not working may be due to my minSdkVersion is 14.

Upvotes: 0

Views: 2973

Answers (1)

Ablo
Ablo

Reputation: 61

in XML add app:labelVisibilityMode="labeled"in BottomNavigationView

Upvotes: 6

Related Questions