简体   繁体   中英

Bottom Navigation View menu item title size

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

在此输入图像描述

  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> 
 <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>

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"
    ...
    ...
 />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM