Reputation: 107
I am trying to use bottom navigation view in my app but I'm having issues getting it to work as it seems to behave differently according to the number of items i am displaying in the bottom navigation view
this is the view when i have only three items in it.
it displays as i want
but when i make it four the view gets bad
it doesn't expand to fit to the edge of my screen it is just positioned at the center of my screen.
below is my activity main layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/main_app_bar"
layout="@layout/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/navigation" />
</android.support.design.widget.CoordinatorLayout>
Upvotes: 2
Views: 123
Reputation: 59
BottomNavigationView has condition: when there is more than 3 items then use shift mode. Review this answer. Visit
Upvotes: 1
Reputation: 404
Since you have more than three items you may have to disable shift mode. Please see the anawer in this question How to disable BottomNavigationView shift mode?
Upvotes: -1
Reputation: 2889
Add label visibility mode to you bottom navigation view
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:labelVisibilityMode="labeled" // this line
android:background="@color/colorPrimary"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/navigation" />
Upvotes: 1