Question

Je vous écris une application qui implémente les onglets imbriqués. Parce que deux ensembles d'onglets occupent un peu d'espace et, en général parce que la nature du contenu je voudrais placer l'ensemble TabHost interne dans une structure scrollable. Je peux faire tabcontent de l'activité extérieure FrameLayout, LinearLayout, même ViewFlipper; lorsque je tente de le faire ScrollView, le programme se bloque.

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

Donc, apparemment TabHost aime vivre à l'intérieur des cadres non défilants. Y at-il moyen de contourner cela sans créer beaucoup de désordre?

Était-ce utile?

La solution

Désolé j'ai tout compris moi-même. La solution consiste à envelopper la deuxième TabHost l'intérieur d'un ScrollView dans son propre fichier XML. Cela fonctionne très bien.

externe:

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

intérieur:

<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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top