Building a precise UI with ConstraintLayout
Open the ConstraintLayout
that was autogenerated when we created the project. It is probably open already in a tab at the top of the editor. If not, it will be in the res/layout
folder. The filename is activity_main.xml
.
Inspect the XML in the Code tab and note that it is empty, apart from a TextView
that says Hello World
. Switch back to the Design
tab, left-click the TextView
to select it, and tap the Delete key to get rid of it.
Now, we can build ourselves a simple yet intricate UI. The ConstraintLayout
is most useful when you want to position parts of your UI very precisely and/or relative to the other parts and not just in a linear fashion.
Adding a CalendarView
To get started, look in the Widgets category of the palette and find the CalendarView
. Drag and drop the CalendarView
near the top and horizontally central. As you drag the CalendarView
around, notice that it jumps/snaps to some locations.
Also, notice the subtle...