15

Is there any way to get the height of BottomNavigationViewheight using XML attribute just like this ?attr/actionBarSize

<com.google.android.material.bottomnavigation.BottomNavigationView 
    android:layout_width="match_parent"
    android:background="@color/whiteColor"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:menu="@menu/bottom_navigation_menu"
    app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
    android:id="@+id/bottomNavigationView"/>
Maddy
  • 4,525
  • 4
  • 33
  • 53
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
  • 2
    yes, I have used ?attr/actionBarSize in my app throughout the BottomNavigationView @Manoj – Brahma Datta Jun 14 '19 at 05:59
  • @BrahmaDatta That's not the exact height of `BottomNavigationView` – Manoj Perumarath Jun 14 '19 at 06:15
  • But it is a fixed height if we put wrap_content then the height may increase depending on the Image height. @Manoj – Brahma Datta Jun 14 '19 at 06:18
  • 1
    The `?attr/actionBarSize` is correct for portrait mode but not for landscape mode. I found that the height of the `BottomNavigaitonView` is `56dp` (see here: https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/bottomnavigation/res/values/dimens.xml) you could use `56dp` in your XML but of course this could change over time. I'm looking into it if the `design_bottom_navigation_height` dimension is accessible in XML (haven't found a way yet). – Bruno Bieri Sep 03 '21 at 07:50

0 Answers0