在表格布局的tabactivities上使用scrollview

时间:2011-03-04 11:35:44

标签: android android-layout

我正在开发一个android-app,它基本上是三个标签,每个标签都有自己的活动类。这是main.xml:

<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:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="0dp">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </TabWidget>
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="0dp">

        <include layout="@layout/sorted_teams" />
        <include layout="@layout/unsorted_teams" />
        <include layout="@layout/about" />
</FrameLayout>        
    </LinearLayout>
    </TabHost>

我有三个包含自己的活动类和布局xml文件。我想要的是每个标签内容的滚动。你会怎么做?我尝试用滚动视图封装不同选项卡的布局文件的全部内容。我使用tablelayout作为每个标签的内容。我尝试用滚动视图封闭整个内容,但它不会出现。如果我希望每个标签的内容可滚动,你会如何推荐使用scrollview?

2 个答案:

答案 0 :(得分:0)

在每个标签活动的每个布局文件中使用ScrollView作为TableLayout的封闭父级。

确保您的滚动视图定义类似于

<ScrollView
      android:layout_height="wrap_content"
      android:layout_width="fill_parent">

答案 1 :(得分:0)

感谢您的快速解答!您发布的解决方案也是我的解决方案,但我错过了一个似乎让每个人都搞砸的细节。

我再次尝试在每个布局中附上一个滚动视图,但我在layout_height上有fill_parent,将其更改为wrap_content似乎解决了所有问题,问题解决了!

我不知道为什么我们将它设置为fill_parent,我认为这是因为背景颜色存在问题。