How to increase Bottom Navigation View height along with its icon and text sizes in android?

倖福魔咒の 提交于 2019-11-30 12:07:49

问题


I am using

compile 'com.android.support:design:25.0.0'

Android Bottom Navigation View and its height is is fixed and tiny icons with small text are shown. My question is how can i increase their sizes? I've tried to change size in xml file through style... all other properties are working except textsize property.

Can i do that pragmatically if so, then please write a code


回答1:


I've found a solution to override some dimen values in dimens.xml file it works for the text size but icon still remains tiny. Here is how i do that. Hope this code will help others too :-)

<!-- Overriding Default Bottom Navigation sizes-->
    <dimen name="design_bottom_navigation_text_size" tools:override="true">16sp</dimen>
    <dimen name="design_bottom_navigation_active_text_size" tools:override="true">20sp</dimen>
    <dimen name="design_bottom_navigation_height" tools:override="true">70dp</dimen>



回答2:


To expand on RamshaS answer for those who are looking to increase other values as well. Here are a list of all the values that can be set

bottom_navigation_elevation
bottom_navigation_height
bottom_navigation_icon
bottom_navigation_margin_bottom
bottom_navigation_margin_top_active
bottom_navigation_margin_top_inactive
bottom_navigation_max_width
bottom_navigation_min_width
bottom_navigation_notification_elevation
bottom_navigation_notification_height
bottom_navigation_notification_margin_left
bottom_navigation_notification_margin_left_active
bottom_navigation_notification_margin_top
bottom_navigation_notification_margin_top_active
bottom_navigation_notification_margin_top_classic
bottom_navigation_notification_padding
bottom_navigation_notification_radius
bottom_navigation_notification_text_size
bottom_navigation_notification_width
bottom_navigation_padding_left
bottom_navigation_padding_right
bottom_navigation_small_active_max_width
bottom_navigation_small_active_min_width
bottom_navigation_small_inactive_max_width
bottom_navigation_small_inactive_min_width
bottom_navigation_small_margin_bottom
bottom_navigation_small_margin_top
bottom_navigation_small_margin_top_active
bottom_navigation_small_selected_width_difference
bottom_navigation_text_size_active
bottom_navigation_text_size_forced_active
bottom_navigation_text_size_forced_inactive
bottom_navigation_text_size_inactive



回答3:


it is default

<dimen name="design_bottom_navigation_active_item_max_width">168dp</dimen>
<dimen name="design_bottom_navigation_active_item_min_width">96dp</dimen>
<dimen name="design_bottom_navigation_active_text_size">14sp</dimen>
<dimen name="design_bottom_navigation_elevation">8dp</dimen>
<dimen name="design_bottom_navigation_height">56dp</dimen>
<dimen name="design_bottom_navigation_icon_size">24dp</dimen>
<dimen name="design_bottom_navigation_item_max_width">96dp</dimen>
<dimen name="design_bottom_navigation_item_min_width">56dp</dimen>
<dimen name="design_bottom_navigation_margin">8dp</dimen>
<dimen name="design_bottom_navigation_shadow_height">1dp</dimen>
<dimen name="design_bottom_navigation_text_size">12sp</dimen>
<color name="design_bottom_navigation_shadow_color">#14000000</color>



回答4:


The correct values of Bottom Navigation that you can override in dimens.xml like @RamshaS replied are the following

design_bottom_navigation_active_item_max_width
design_bottom_navigation_active_text_size
design_bottom_navigation_elevation
design_bottom_navigation_height
design_bottom_navigation_item_max_width
design_bottom_navigation_item_min_width
design_bottom_navigation_margin
design_bottom_navigation_shadow_height
design_bottom_navigation_text_size
design_bottom_navigation_item_background
design_bottom_navigation_item
design_bottom_navigation_shadow_color

I tried to set many values of @Kobus Pitzer's list but in dimens.xml with overriding mode not working. They are probably values that can overriden by code and not by dimens.xml




回答5:


I used scaleX and scaleY on the BottomNavigationView, with adding start and end padding to adjust the bottombar icons into desired position. Solves the icon and text size problem for different screen sizes.



来源:https://stackoverflow.com/questions/42318954/how-to-increase-bottom-navigation-view-height-along-with-its-icon-and-text-sizes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!