Introducing layouts
We have already seen ConstraintLayout
in Chapter 1, Beginning Android and Java, but there are more layouts than this. Layouts are the building blocks that group together the other UI elements. Layouts can also contain other layouts.
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 will therefore expand our horizons in terms of what is possible.
We have already seen that once we have designed a layout, we can put it into action with the setContentView
method in our Java code.
Let's build three designs with different layout types, and then put setContentView
to work and switch between them.
Creating and exploring a layout project
One of the toughest things in Android is not just finding out how to do something but finding out how to do something in a particular context. That is why throughout this book, as well as showing...