Android Programming with Kotlin for Beginners
上QQ阅读APP看书,第一时间看更新

Layouts

We have already seen ConstraintLayout, but there are more. Layouts are the building blocks that group together the other UI elements/widgets. Layouts can, and often do, contain other layouts themselves.

Let's look at some commonly used layouts in Android, because knowing the different layouts and their pros and cons will make us more aware of what can be achieved, and therefore will expand our horizons of what is possible.

We have already seen that, once we have designed a layout, we can put it into action using the setContentView function in our Kotlin code.

Let's build three designs with different layout types and then put setContentView to work and switch between them.