2012-02-24 42 views
0

我有一個底部標籤的佈局。但是,我無法在tabHost頂部設置條。怎麼做?謝謝。android get tab strip on bottom tabHost

這裏我主要佈局:

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

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

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" > 
     </FrameLayout> 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent"      
      android:layout_height="wrap_content" 
      android:layout_weight="0" 

    /> 
    </LinearLayout> 

</TabHost> 

,也爲標籤的風格選擇:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

<item android:state_pressed="true" > 
    <shape> 
     <gradient 
      android:startColor="#aa3434" 
      android:endColor="#432233" 
      android:angle="270" 
      /> 
    </shape> 
</item> 

<item android:state_selected="true" > 
    <shape> 
     <gradient 
      android:startColor="#aa3434" 
      android:endColor="#432233" 
      android:angle="270" /> 
    </shape> 
</item> 

enter image description here

回答

0

試試這個代碼

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" /> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="0dip" 
      android:layout_weight="1" /> 
    </LinearLayout> 

</TabHost> 
+0

嘗試,但沒有改變: ( – Jaume 2012-02-24 12:25:51

+0

這個代碼已經在我的項目 – 2012-02-24 12:29:29

+0

中實現了,同樣在底部使用了選項卡? – Jaume 2012-02-24 12:58:24