【发布时间】:2011-08-05 10:55:24
【问题描述】:
我有带有三个标签的 TabHost。这些选项卡之一包含 ListActivity。我希望所有三个选项卡都是可滚动的。起初我将 FrameLayout(tabcontent) 放在 ScrollView 中,但我不能将 ListActivity 放在 ScrollView 中,所以我为每个选项卡添加了 ScrollView(除了第三个带有 ListActivity 的选项卡)。现在滚动仅适用于第二个选项卡。当我尝试第一个滚动时,滚动条正在移动,但内容却没有。即使我在第一个选项卡上,看起来只有包含第二个选项卡的 ScrollView 具有焦点。
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- TAB1 -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/tab1Layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TextView
anddroid:id="@+id/textview11"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
anddroid:id="@+id/textview12"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
anddroid:id="@+id/textview13"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
anddroid:id="@+id/textview14"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<!-- FEW MORE TEXTVIEWS -->
</LinearLayout>
</ScrollView>
<!-- TAB 2 -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/tab2Layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TextView
anddroid:id="@+id/textview21"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
anddroid:id="@+id/textview22"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
anddroid:id="@+id/textview23"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
anddroid:id="@+id/textview24"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<!-- FEW MORE TEXTVIEWS -->
</LinearLayout>
</ScrollView>
<!-- TAB3 -->
<!-- ListActivity here -->
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
【问题讨论】: