我找到了这个简单的布局作为示例:
<?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" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" />
</HorizontalScrollView>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>
在代码中添加 8 个选项卡后,我可以看到它们被挤在一起。 如何向选项卡添加可滚动功能? (只是选项卡,不是内容)
我手机上的一个应用程序具有此功能,并且也是在没有任何滚动条的情况下完成的。基本上,要移动,我只需按下并按住,然后将选项卡拖动到左侧即可显示更多选项卡。如何实现这一目标?
最佳答案
你试过这个吗?
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</TabHost>
</HorizontalScrollView>
关于java - Android 2.3.3,使选项卡列表可滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10880978/