Android-TabHost内置ScrollView
我正在编写一个实现嵌套选项卡的应用程序。由于两组选项卡占据了相当大的空间,而且通常由于内容的性质,我想将整个内部TabHost放入一个可滚动的结构中。我可以使选项卡内容的外部活动框架布局,线性布局,甚至ViewFlipper;当我试图使其成为ScrollView时,程序崩溃Android-TabHost内置ScrollView,android,scrollview,android-tabhost,tabwidget,android-xml,Android,Scrollview,Android Tabhost,Tabwidget,Android Xml,我正在编写一个实现嵌套选项卡的应用程序。由于两组选项卡占据了相当大的空间,而且通常由于内容的性质,我想将整个内部TabHost放入一个可滚动的结构中。我可以使选项卡内容的外部活动框架布局,线性布局,甚至ViewFlipper;当我试图使其成为ScrollView时,程序崩溃 <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost"
<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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ScrollView
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
显然TabHost喜欢生活在不可滚动的框架内。有没有办法在不造成一片混乱的情况下解决这个问题?对不起,我自己弄明白了。解决方案是将第二个TabHost包装在ScrollView中,并保存在它自己的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">
<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"/>
</LinearLayout>
</TabHost>
内部:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ViewFlipper
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</ScrollView>