3

I'm using roughike to implement bottom bar navigation in my android project. I'm not using any icon image as I felt using image & maintain resolution ratio is more complicated than using fontawesome icons. So I've written the code this way:

<com.roughike.bottombar.BottomBar
    android:id="@+id/menu_bottomBar"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    app:bb_titleTypeFace="fonts/fontawesome.ttf"
    android:layout_alignParentBottom="true"
    app:bb_tabXmlResource="@xml/bottombar_tabs" />

Tabs is define in bottombar_tabs.xml file:

<tabs>
    <tab
        id="@+id/tab_home"
        title="\uf278" />
    <tab
        id="@+id/tab_chat"
        title="\uf0e6" />
    <tab
        id="@+id/tab_globe"
        title="\uf0ac" />
    <tab
        id="@+id/tab_friends"
        title="\uf0c0" />
    <tab
        id="@+id/tab_profile"
        title="\uf2be" />
</tabs>

navigation functions working properly as expected but all tabs title showing in the top of navigation. How do I make it vertically centered? I tried using gravity,layout_gravity but nothing worked. Appriciate your help, Thanks, Robin

https://github.com/roughike/BottomBar

Asif Patel
  • 1,744
  • 1
  • 20
  • 27
Robin
  • 446
  • 2
  • 4
  • 24

1 Answers1

1

You can try to do is to change container gravity (container is what hosts tab Views like ImageView, TextView etc)

for (int i = 0; i < mBottomBar.getTabCount(); i++) {
      mBottomBar.getTabAtPosition(i).setGravity(Gravity.CENTER_VERTICAL);
  }
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62