3

我正在使用粗糙的在我的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

回答

1

你可以尝试做的是改变容器gravity(容器是什么主机标签ViewsImageViewTextView等)

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

运行完美!非常感谢:) –

+0

thnkx.do upvote如果帮助! – rafsanahmad007