6
當前我正在嘗試爲我的項目實現FragmentTabHost。我在這個片段上仍然是新的,但是我發現它在重用佈局等方面非常出色,這就是爲什麼我想要進一步推進自己。現在,我讀了如何創建片段選項卡教程,我來到這個教程:自定義FragmentTabHost在底部設置TabWidget
現在,這工作得很好,除了tabWidget是我的佈局,我想它的頂部在底部。我發現我需要設置tabWidget所有選項卡已初始化後,所以我嘗試添加這些代碼:
mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
mTabWidget.setBackgroundColor(Color.WHITE);
mTabWidget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
mTabWidget.setGravity(Gravity.BOTTOM);
現在這一個已經消除了分頻器和改變顏色,但顯然不會把我的Widget在我的佈局的底部。現在我該怎麼做?
我也嘗試編輯Tabhost xml,並將TabWidget放在FrameLayout之後,但沒有任何反應。這裏的XML:
<android.support.v4.app.FragmentTabHost
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/tabFrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
目前檢查出來。 :) – KaHeL
嗨Gru,測試它,是的它的工作!但我有一個問題。 tabDividers顯示,我不知道將它關閉。以及我不能改變標籤的顏色。我應該怎麼做? – KaHeL
我已經得到它! :)) 非常感謝! – KaHeL