Item showing only on click on BottomNavigationView

Viewed 2210

So I want a navigation bar at the bottom of the screen with 4 items but for some reason only the first one is showing and the others appear only when i click them.

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="@color/white"
    app:itemTextColor="@color/black"
    app:menu="@menu/navigation_bar_bottom_menu" />

My menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/nav_home"
    android:title="@string/navigation_bar_home_text" />

<item
    android:id="@+id/nav_inbox"
    android:title="@string/navigation_bar_inbox_text" />

<item
    android:id="@+id/nav_notes"
    android:title="@string/navigation_bar_notes_text" />

<item
    android:id="@+id/nav_profile"
    android:title="@string/navigation_bar_profile_text" />

</menu>

The bar is displayed like this just with the first item showing:

enter image description here

2 Answers
     <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@color/gray_background"
        app:itemIconTint="@color/nav_item_state_list"
        app:itemTextColor="@color/nav_item_state_list"
        app:labelVisibilityMode="labeled"
        android:theme="@style/Widget.BottomNavigationView"
        app:menu="@menu/bottom_navigation_items"/>



<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/colorPrimaryLite"
          android:state_pressed="true"/>
    <item android:color="@color/colorPrimaryLite"
          android:state_checked="true"/>
    <item android:color="@color/grayDark"
          android:state_checked="false"/>
    <item android:color="@color/white"/>
</selector>

Here is the example

Create a color file navigation_item_text_color.xml

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

then put to color folder (if you don't have color folder -> just create it manually)

Then

<com.google.android.material.bottomnavigation.BottomNavigationView
    ...
    app:itemTextColor="@color/navigation_item_text_color" />

More

If you bottom menu item have icon, you can change icon color like app:itemIconTint="@color/navigation_item_text_color"

Related