The ScrollView along with a LinearLayout allows us to have a number of visual components that exceed the amount of space of the viewer of the phone or tablet. Then the user can move the created interface with his finger.

Problem:

Create a project called: Proyecto023 and have control ScrollView type (found in the “Containers” tab) as we can control then we will see that our Scroll View is within “Linear Layout” control:

 

Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin -

Now we will have 20 objects of class within the LinearLayout Button (we can do it directly in the window or by dragging the buttons to the “Component Tree” window within the object “LinearLayout”):

 

Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin -

We continue dragging buttons inside the LinearLayout until we reach 20 (then change the text property), as we can see there are more buttons inside the LinearLayout than the ones that can be displayed in the interface of the device:

 

Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin -

Thanks to the functionality of the ScrollView next to LinearLayout now at runtime we can scroll:

 

Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin - Lesson: 21 - Layout (ScrollView and LinearLayout) in Kotlin -

We can arrange objects of different types within the LinearLayout (Button, EditText, TextView, etc.)

…..

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!