2

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

4 Answers 4

4

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I wasn't sure if this was possible, but I will give it a shot. With a simple addition of <LinearLayout> </LinearLayout> around all other layouts work?
Yep, I need 10 more characters, there they are ;)
When I add the tags around the other layouts, it crashes :(
You need to be more specific. What does the logcat say? Also, try cleaning first. "Project --> Clean..."
Okay, the problem is I don't know the exact length and width to wrap around the other layouts
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>

1 Comment

Yes... thats the issue. How can I go about making them all scrollable?
1

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>

1 Comment

Is there anyway to work backwards? ie. I have my linear layouts already set, but I need to wrap them now with a linear layout
0
<ScrollView 
   <LinearLayout     // Your Main Layout 
       <LinearLayout   // Child Layout 1st
       </LinearLayout>

       <LinearLayout   // Child Layout 2nd
       </LinearLayout>

       <LinearLayout   // Child Layout 3rd
       </LinearLayout>

   </LinearLayout>
</ScrollView>

Try to use about format.

Hope it helps.

Regards

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.