Download presentation
Presentation is loading. Please wait.
1
Android Studio Constraint Layout
2
In activity_main.xml, Design view, click on an item (either in component tree or on Design)
3
One can toggle back and forth between a list of “all properties” (seen on right) and select properties and a constraint diagram (on left).
4
If you have the layout as a whole selected there is no constraint diagram. (Items can be constrained to the overall layout, but it in not constrained to anything)
5
The initial TextView is constrained to its parent (container) at top and bottom – making it centered vertically – as well as at left and right – making it centered horizontally
6
The corresponding text
7
A newly dragged out TextView is unconstrained.
8
Corresponding text: layout_editor attribute does nothing when it runs
Corresponding text: layout_editor attribute does nothing when it runs. Also red squiggly line is telling you item is unconstrained.
9
The item’s top can be constrained to the top of its parent container when in Design by clicking on the little circle at the top and dragging to the top of the container.
10
Similarly drag circle on left of item to left of container
11
After dragging out a plain-text EditText, it is similarly unconstrained.
12
Drag its top circle to the top of the parent container
Drag its top circle to the top of the parent container. Drag its left circle to the right of the TextView previously put down (and given id of txtName)
13
Magnified one can see the left of the EditText connected to the right of the TextView
14
Seen in Text
15
Because the EditText in the “first row” takes up more space vertically, the next TextView’s top should be constrained to its bottom.
16
Text version (second TextView)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.