Search code examples
androidbottomnavigationview

BottomNavigationView navigation items text displayed above icon


After upgrading dependency:

'com.google.android.material:material:x.x.x'

from 1.4.0 to 1.5.0, the navigation items text has somehow changed from being anchored below the icon to on top of it:

From:

enter image description here

To:

enter image description here

Is this a feature or a bug and does this have a fix?


Solution

  • I was facing the same problem after updating from 1.4.0 to 1.5.0, but in my case the problem was caused because I was using a theme for the BottomNavigationView that inherited from Widget.Design.BottomNavigationView:

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bnv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?android:attr/windowBackground"
        android:theme="@style/Widget.BottomNavigationView"
        ...
    />
    

    After looking at the Widget.Design.BottomNavigationView xml I realised that in version 1.5.0 a minHeight attribute has been added, causing the problem affecting us.

    So I added <item name="android:minHeight">0dp</item> to my custom style like this:

    <style name="Widget.BottomNavigationView" parent="Widget.Design.BottomNavigationView">
        ...
        <item name="android:minHeight">0dp</item>
    </style>
    

    And the problem was solved!