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?

1
  • I would just make my own custom. Its not that hard. I can help you if you want. Commented Aug 11, 2017 at 18:31

3 Answers 3

1

dont put iandroid:icon property to your item

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.