Search code examples
androidxmllayoutscrollviewerviewflipper

What do I do if I have a ViewFlipper and ScrollView only wraps one child?


I really only need my ScrollView wrapped around 1 of the 3 LinearLayouts I have in my ViewFlipper, but I try to wrap it around my 3rd child and it gives me the error that ScrollView can only host one direct child.

Any workarounds?

<ViewFlipper>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ScrollView android:id="@+id/ScrollView01"
             android:layout_width="fill_parent"
             android:layout_height="110dp">

      <!--- Stuff --->

        </ScrollView>
    </LinearLayout>
</ViewFlipper>

Solution

  • Sure - make the one child of your ScrollView a FrameLayout, LinearLayout or RelativeLayout and put the content in that.