2011-03-04 60 views
1

我开发的Android应用程序基本上是三个选项卡,每个选项卡都有自己的活动类。这里是main.xml:使用表格布局的Tabactivities上的滚动视图

<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?

回答

0

在每个选项卡活动的每个布局文件中,使用ScrollView作为TableLayout的封闭父项。

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

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

谢谢你的快速解答!您发布的解决方案也是我的解决方案,但我错过了一个似乎将每件事情都搞得一团糟的细节。

我再次尝试用每个布局中的滚动视图进行封闭,但是我在layout_height上填充了fill_parent,将其更改为wrap_content似乎解决了所有问题,解决了问题!

我不知道为什么我们将它设置为fill_parent,我认为这是因为某些问题与背景颜色有关。