我目前正在研究我的第一个android应用程序。我正在为我的应用程序使用选项卡式布局。我在开发指南中跟随了这个教程,并遇到了一个问题。本教程仅使用三个选项卡,但我需要更多。因此,选项卡调整大小和聚集。我希望有人能告诉我如何让他们滚动,如使用多个选项卡时在海豚浏览器中。谢谢!Android:滚动标签
〜aaron
我目前正在研究我的第一个android应用程序。我正在为我的应用程序使用选项卡式布局。我在开发指南中跟随了这个教程,并遇到了一个问题。本教程仅使用三个选项卡,但我需要更多。因此,选项卡调整大小和聚集。我希望有人能告诉我如何让他们滚动,如使用多个选项卡时在海豚浏览器中。谢谢!Android:滚动标签
〜aaron
在这种情况下,您可能不想使用选项卡。相反,你可以在包裹在一个滚动型这样
<?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>
我认为这会给你你正在寻找的结果屏幕的顶部把所有的“标签”中的水平线性布局,但让我知道
我会建议包装与HotizontalScrollView而不是TabWidget。这样你仍然可以使用这些标签。
<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>
要注意,如果你正在使用更少的标签,这将导致该标签的不填充屏幕的整个宽度是很重要的。我目前正在为这个问题寻找解决方案。
使用什么约尔说,只需添加: 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而不是滚动型(其垂直滚动只) – mtmurdock 2010-06-19 16:29:21
谢谢。我将尝试以这种方式实施并让你知道。 – ariets 2010-06-23 05:01:17
清晰简单.... !!! – 2013-08-16 09:38:43