Home » Android » android – Bottom Navigation View menu item title size

android – Bottom Navigation View menu item title size

Posted by: admin June 15, 2020 Leave a comment

Questions:

Good Morning,

i am using bottom navigation view to do my bottom menu.

and now the title is too big and i can’t found any solution to solve it

enter image description here

How to&Answers:
  1. Open values\dimens.xml
  2. add this code

    <dimen 
          name="design_bottom_navigation_text_size"   
          tools:override="true">11sp </dimen>
    
    <dimen 
          name="design_bottom_navigation_active_text_size" 
          tools:override="true">12sp </dimen>
    

Answer:

 <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_gravity="bottom"
        android:background="@color/bg_grey"
      app:itemTextAppearanceActive="@style/BottomNavigationView.Active"
        app:itemTextAppearanceInactive="@style/BottomNavigationView"
        app:itemTextColor="@color/bottom_nav_color"
        app:labelVisibilityMode="labeled"
        app:menu="@menu/bottom_navigation_menu" />

styles.xml

<style name="BottomNavigationView" parent="@style/TextAppearance.AppCompat.Caption">
    <item name="android:textSize">10sp</item>
</style>

<style name="BottomNavigationView.Active" parent="@style/TextAppearance.AppCompat.Caption">
    <item name="android:textSize">11sp</item>

Answer:

Create new style

<style name="NavigationViewOwnStyle">
 <item name="android:listPreferredItemHeightSmall">40dp</item><!-item height-->
 <item name="android:textSize">20sp</item> <!--item text size-->
</style>

and apply

<android.support.design.widget.NavigationView
    ...
    ...
    app:itemTextAppearance="@style/NavigationViewOwnStyle"
    ...
    ...
 />