0

I need that BottomNavigationView to be responsive. When I use a Nexus 4 it has the exact measurement, but with Nexus 6 it does not. Any idea?

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    app:itemIconTint="@drawable/selector"
    app:itemTextColor="@color/colorPrimary"
    android:background="?android:attr/windowBackground"
    app:menu="@menu/navigation"/>
ocollp
  • 3
  • 1

4 Answers4

0

Set layout_height attribute to wrap_content instead of match_parent:

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" //modify this line
    android:layout_gravity="bottom"
    app:itemIconTint="@drawable/selector"
    app:itemTextColor="@color/colorPrimary"
    android:background="?android:attr/windowBackground"
    app:menu="@menu/navigation"/>
AlexTa
  • 5,133
  • 3
  • 29
  • 46
0

because the height is matching_parent!! so it depends of how the parent is composed and adapting the views, for this case is better to have a fix value width or setup to wrap_content but then you have to take care of size of icons!

VITROXMAN
  • 216
  • 2
  • 5
0

If you are talking about the width not matching the parent, check this answer. You have to play with the background by setting its color with the same color as the item

 android:background="@color/bottom_view_color"
 app:itemBackground="@color/bottom_view_color"
fedepaol
  • 6,834
  • 3
  • 27
  • 34
0

Use BottomNavigationView height as android:layout_height="wrap_content" or android:layout_height="56dp".

See documentation about height.

Ferdous Ahamed
  • 21,438
  • 5
  • 52
  • 61