在普遍接受的慣例,標籤適應整個屏幕。 大多數人(包括我)都不知道標籤可以放在任何地方,就像一個簡單的視圖ListView。 訣竅是將您的TabHost包含在另一個佈局中。當您創建TabHost,始終保持這些ID:tabhost,標籤,tabcontent
在主佈局,包括您tabhost.xml。在這裏我中心TabHost中間
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- Fill whatever you need -->
<FrameLayout
android:id="@+id/widget_fragment"
android:layout_centerVertical="true" android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<include layout="@layout/tabhost" />
</FrameLayout>
</LinearLayout>
在Support4Demos的標籤和TabsPager例子看看好了,TabHost仍然由FragmentActivity管理。每個標籤內容都是一個片段。隨着TabActivity,也未必能在任何地方
在最後一個標籤,這是什麼樣子
而當你試圖「無微不至」,發生了什麼? – CommonsWare
沒有工作,這就是爲什麼我問:)。試圖在Fragment內部實現它,就像在演示中的FragmentActivity內完成它一樣。 –
請定義「沒有工作」。 – CommonsWare