无法使 roughike 底部栏导航标题居中

Can't make roughike bottom bar navigation title centered

我正在使用 roughike 在我的 android 项目中实现底部栏导航。我没有使用任何图标图像,因为我觉得使用图像和保持分辨率比使用 fontawesome 图标更复杂。所以我这样写代码:

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

制表符在 bottombar_tabs.xml 文件中定义:

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

导航功能按预期正常工作,但所有选项卡标题都显示在导航顶部。如何使其垂直居中?我尝试使用重力,layout_gravity 但没有任何效果。 感谢您的帮助,谢谢, 罗宾

https://github.com/roughike/BottomBar

您可以尝试更改容器 gravity(容器是主机选项卡 Views,如 ImageViewTextView 等)

for (int i = 0; i < mBottomBar.getTabCount(); i++) {
      mBottomBar.getTabAtPosition(i).setGravity(Gravity.CENTER_VERTICAL);
  }