Android -Tabhost Inside Scrollview
-
26-10-2019 - |
質問
ネストされたタブを実装するアプリを書いています。 2セットのタブがかなりのスペースを占有しているため、一般的に内側のタブホスト全体をスクロール可能な構造に配置したいコンテンツの性質であるためです。外側のアクティビティのタブコンテンントを作成できます。 ScrollViewにしようとすると、プログラムはクラッシュします。
<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は、非スクロール可能なフレームの中に住むことを好むようです。たくさんの混乱を生み出すことなく、これを回避する方法はありますか?
解決
申し訳ありませんが、自分でそれを理解しました。解決策は、独自のXMLファイル内のScrollView内に2番目の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" />
<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>
所属していません StackOverflow