我想設置的選項卡host.in標籤滾動條也爲五片,但我想在一個時間顯示只有三個 標籤,以及如何使滾動條爲使標籤能滾動查看更多選項卡......請給我提供了一些解決方案.......如何設置選項卡主機滾動條
這爲m的xml文件.....
<RelativeLayout
android:id="@+id/rl3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/gray" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/layTab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:gravity="center" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
</HorizontalScrollView>
</RelativeLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" >
<fragment
android:id="@+id/fragment1"
android:name="info.tech.slidermenu.Home_feed"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="50dp" />
<fragment
android:id="@+id/fragment2"
android:name="info.tech.slidermenu.Upcoming_tennise_match"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="50dp" />
<fragment
android:id="@+id/fragment3"
android:name="info.tech.slidermenu.Upcoming_tennise_match"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="50dp" />
<fragment
android:id="@+id/fragment4"
android:name="info.tech.slidermenu.Upcoming_tennise_match"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="50dp" />
<fragment
android:id="@+id/fragment5"
android:name="info.tech.slidermenu.Upcoming_tennise_match"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="50dp" />
</FrameLayout>
</RelativeLayout>
</TabHost>
</RelativeLayout>
這是類文件....
public void tabselect() {
TabHost tab = (TabHost) findViewById(R.id.tabhost);
tab.setup();
tab.setHorizontalScrollBarEnabled(true);
TabHost.TabSpec spec = tab.newTabSpec("tab1");
spec.setContent(R.id.fragment1);
spec.setIndicator("Feed");
tab.addTab(spec);
spec = tab.newTabSpec("tab2");
spec.setContent(R.id.fragment2);
spec.setIndicator("tennis");
tab.addTab(spec);
spec = tab.newTabSpec("tab3");
spec.setContent(R.id.fragment3);
spec.setIndicator("boxing");
tab.addTab(spec);
spec = tab.newTabSpec("tab3");
spec.setContent(R.id.fragment4);
spec.setIndicator("cricket");
tab.addTab(spec);
spec = tab.newTabSpec("tab3");
spec.setContent(R.id.fragment5);
spec.setIndicator("base ball");
tab.addTab(spec);
tab.setCurrentTab(0);
}
截屏....
如果你還沒有走你的代碼。我建議使用View Pager和PageStrip。它們通過翻轉屏幕來提供滾動,另外它還使用片段以及TabHost也被棄用。 http://howrobotswork.wordpress.com/2013/06/22/how-to-use-the-pagertabstrip-and-the-pagertitlestrip/你一定會得到更多的例子ob PageStrip。只是谷歌。 :) –
你能幫助我如何使用它與此代碼.. – bhavdip
請實施一個fragmentTab,你使用的代碼將不會感覺好,一旦你前進的工作。 http://www.codeproject.com/Articles/678093/Fragments-Creating-a-Tabbed-Android-User-與您不必擔心屏幕大小的片段接口,您的選項卡將自動調整。 – Skynet