【问题标题】:TabHost with tabs inside scrollviews - scrolling works only for one tabTabHost 在滚动视图中带有标签 - 滚动仅适用于一个标签
【发布时间】: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>

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    不是这样的

    您不能为选项卡使用单独的滚动视图或任何视图 TabWidget 它本身包含选项卡和内容您可以使用 FramLayout 这个 FramLayout 将包含您想要通过单击 Tab 打开的 Activity。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多