2014-04-01 53 views
0

我想對齊屏幕底部的標籤我試圖用alignParentBottom'true'做相對佈局,但沒有成功。任何人都可以引導我嗎?如何在fragmenttabhost屏幕底部對齊標籤

<android.support.v4.app.FragmentTabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <TabWidget 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" 
      android:orientation="horizontal" /> 

     <FrameLayout 
      android:id="@+id/tabFrameLayout" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 
    </LinearLayout> 

</android.support.v4.app.FragmentTabHost> 
+1

標籤應始終在一個頂部droid –

+0

我發佈我的代碼,你只是用它...我希望它會幫助你... –

回答

0

你只需要添加這兩條線到你的標籤控件這一切......

 <TabWidget 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:gravity="bottom" 
     android:layout_weight="0" 
     android:orientation="horizontal" /> 
+0

它也不工作。 – user3484050

0

這是不好的做法,設在底部的標籤,但如果你需要,隱藏重量Android小工具= 0並用自己的「realcontent」工作FrameLayut

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="0dp" 
      android:layout_height="0dp" 
      android:layout_weight="0"/> 
     <FrameLayout 
      android:id="@+android:id/realtabcontent" 
      android:background="@drawable/bg_main_app_gradient" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"/> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:background="#EAE7E1" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0"/> 
    </LinearLayout> 
</TabHost> 

https://stackoverflow.com/a/23150258/2765497