Android Bottom Navigation: space between icon and text

Viewed 1127

How to change the vertical space between icon and text in BottomNavigation programmatically? The only way I found is to modify dimens.xml:

<dimen name="design_bottom_navigation_height" tools:override="true">60dp</dimen>

But it's not possible to modify dimens from the code. What should I do? How to find which parameter is changing when we modify "design_bottom_navigation_height"? Thanks in advance.

1 Answers

Put this on your theme

<style name="text_active">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/red_button</item>
</style>

<style name="text_inactive">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/your_navigation_background_color</item>
</style>

and then assign them to the bottom navigation view like this

app:itemTextAppearanceActive="@style/text_active"
app:itemTextAppearanceInactive="@style/text_inactive"
app:labelVisibilityMode="labeled"
Related