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

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:

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”):

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:

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

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