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