0

My BottonNavigationView not show other options, beyond the selected item. I did trying set a text color, but the color that has been changed is of the selected item.

enter image description here

    <android.support.design.widget.BottomNavigationView
    app:menu="@menu/menu_bottom"
    android:id="@+id/bottomNavigationView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/darker_gray"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Augusto
  • 3,825
  • 9
  • 45
  • 93

1 Answers1

0

You should be able to set colors with these parameters:

app:itemBackground
app:itemIconTint
app:itemTextColor

Here is the full code that I'm using:

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="@dimen/bottom_navigation_height"
    app:itemBackground="@color/white"
    app:itemIconTint="@color/bottom_bar_item_selector"
    app:itemTextColor="@color/bottom_bar_item_selector"
    app:menu="@menu/bottom_navigation_main" />

@color/bottom_bar_item_selector.xml:

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

@menu/bottom_navigation_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/bottom_bar_item_item1"
        android:icon="@drawable/ic_1"
        android:title="@string/unions"
        app:showAsAction="ifRoom"
        android:enabled="true" />
    <item
        android:id="@+id/bottom_bar_item_item2"
        android:icon="@drawable/ic_2"
        android:title="@string/news"
        app:showAsAction="ifRoom"
        android:enabled="true" />
    <item
        android:id="@+id/bottom_bar_item_item3"
        android:icon="@drawable/ic_3"
        android:title="@string/dictionary"
        app:showAsAction="ifRoom"
        android:enabled="true" />
    <item
        android:id="@+id/bottom_bar_item_item4"
        android:icon="@drawable/ic_4"
        android:title="@string/laws"
        app:showAsAction="ifRoom"
        android:enabled="true" />
    <item
        android:id="@+id/bottom_bar_item_item5"
        android:icon="@drawable/ic_5"
        android:title="@string/for_members"
        app:showAsAction="ifRoom"
        android:enabled="true" />
</menu>
Micer
  • 8,731
  • 3
  • 79
  • 73
  • Which folder you create the selector? The option "color" not complete automatically – Augusto Mar 10 '18 at 18:32
  • All in all, Not works. I create on Drawable folder and copy and paste your code, the itens keeping invisibles. – Augusto Mar 10 '18 at 18:43
  • Solve -> https://stackoverflow.com/questions/40176244/how-to-disable-bottomnavigationview-shift-mode – Augusto Mar 10 '18 at 19:17
  • `@color` means file `values/colors.xml`. I thought you need to have all texts and icons visible. – Micer Mar 10 '18 at 19:57