Scrollview multiple LinearLayouts

11,597

Solution 1

Just have one LinearLayout that contains all other LInearLayouts

From Docs

... meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects

This means that it can have only one direct child (the main LinearLayout) but that one child can have its own children.

Solution 2

ScrollView can have only one direct child

so use one Layout that will Contain all your Layouts

Like

<ScrollView  .....>
<LinearLayout .....>

   .............Your All other Layouts .................

</LinearLayout>
</ScrollView>

Solution 3

You have to take your time and do it one at a time. As Tarsem said, you can put one layout inside this scrollview

<ScrollView  .....>
<LinearLayout .....>
      //Inside this layout, you can another scroll view.
           <ScrollView  .....>
              <LinearLayout .....>

                       .............All your other Layouts .................
                     //continue adding them until you add your last scroll view.  if that 
                      is the desire layout.
                </LinearLayout>
             </ScrollView>

</LinearLayout>
</ScrollView>
Share:
11,597
user1580457
Author by

user1580457

Updated on June 13, 2022

Comments

  • user1580457
    user1580457 almost 2 years

    So I have multiple linearlayouts (4) and I would like to have them all in a scrollview. These layouts are used for input fields that are separated by column/category Names, Ages, Occupation, and Country of Residence.

    Each one of these has their own linearlayout. Is there a way to make them all scrollable simultaneously (since scrollview only supports 1 child)?