我目前正在开发我的第一个Android应用程序。我在我的应用程序中使用了选项卡布局。我按照开发指南上的教程进行了操作,但遇到了一个问题。该教程只使用了三个选项卡,但我需要更多。因此,选项卡会调整大小并挤在一起。我希望有人告诉我如何使它们像Dolphin浏览器在使用多个选项卡时一样滚动。谢谢!
根据Yoel所说,只需添加以下内容:
android:fillViewport="true"
以及
android:scrollbars="none"
将其添加到HorizontalScrollView中,就像这样:
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
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="fill_parent"
android:layout_height="wrap_content" />
</HorizontalScrollView>
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</HorizontalScrollView>
需要注意的是,如果您使用较少的标签,这将导致选项卡未填满屏幕的整个宽度。我目前正在寻找解决此问题的方法。
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout
android:orientation="horizontal" android:layout_height="wrap_content"
android:layout_width="fill_parent">
...buttons go here...
</LinearLayout>
</HorizontalScrollView>
我认为这将给你想要的结果,但是让我知道