5

I want my menu items on the BottomNavigationBar to have text-only labels with no icon. Unfortunately, it looks like design_bottom_navigation_item.xml always has a 24x24dp space reserved for the icon, with no publicly-exposed way to set it to gone. And even after getting past that, the label layout is set to a layout_gravity of bottom|center_horizontal, and it doesn't look like there's a way to programatically set layout_gravity to centered.

What is the fastest, easiest way to achieve the goal of a text-only menu item on the bottom nav bar? I'm thinking I can do this by creating a custom version of the item layout, then subclassing BottomNavigationItemView, BottomNavigationMenuView, and BottomNavigationView to specify that custom layout... but that seems like an awful lot of work for one little change. Am I missing something simpler?

Norman Lee
  • 389
  • 3
  • 10

3 Answers3

1

dont put iandroid:icon property to your item

celilshn
  • 11
  • 1
0

Just use the code below. I tried hard to do this easy way but failed.Then I made an alternative. Just use transparent color instead of icon drawble

<item
    android:icon="@android:color/transparent"
    android:id="@+id/navigation_id"
    android:title="title" />
Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42
0

Add this in your dimens file. Then you can add padding according to your navigation view size.

<dimen name="design_bottom_navigation_height"tools:override="true">30dp</dimen>
Zain
  • 37,492
  • 7
  • 60
  • 84