BottomNavbar breaks when you add more than 3 elements

DarknessPlusPlus :

I am working on an android application and it was agreed to only have 3 fragments in its bottom navigation bar. However, things have expanded and we decided to add another fragment. When adding the 4th fragment, the dimensions of the container break making it look like this.

enter image description here

This is my xml code.

    <com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:itemBackground="@color/colorPrimary"
    app:itemIconTint="@drawable/selector"
    app:itemTextColor="@drawable/selector"
    app:menu="@menu/menu_navigation" />

I have tried different properties to make it stretch but they end up putting it only to the right and not expanding left or vice versa. For instance if I was to try using wrap_content on the layout_width, the container would glue itself to the left.

What is the needed property that might be a solution to the problem?

Ezzy :

It's an automatic measure in order to not have labels overlap. You can make a quick fix by adding app:labelVisibilityMode="labeled" to your xml.

Note that you should use Use Support Library 28 for this.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=276400&siteId=1