Android Studio Constraint Layout In activitymain xml Design

  • Slides: 16
Download presentation
Android Studio Constraint Layout

Android Studio Constraint Layout

In activity_main. xml, Design view, click on an item (either in component tree or

In activity_main. xml, Design view, click on an item (either in component tree or on Design)

One can toggle back and forth between a list of “all properties” (seen on

One can toggle back and forth between a list of “all properties” (seen on right) and select properties and a constraint diagram (on left).

If you have the layout as a whole selected there is no constraint diagram.

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)

The initial Text. View is constrained to its parent (container) at top and bottom

The initial Text. View 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

The corresponding text

The corresponding text

A newly dragged out Text. View is unconstrained.

A newly dragged out Text. View is unconstrained.

Corresponding text: layout_editor attribute does nothing when it runs. Also red squiggly line is

Corresponding text: layout_editor attribute does nothing when it runs. Also red squiggly line is telling you item is unconstrained.

The item’s top can be constrained to the top of its parent container when

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.

Similarly drag circle on left of item to left of container

Similarly drag circle on left of item to left of container

After dragging out a plain-text Edit. Text, it is similarly unconstrained.

After dragging out a plain-text Edit. Text, it is similarly unconstrained.

Drag its top circle to the top of the parent container. Drag its left

Drag its top circle to the top of the parent container. Drag its left circle to the right of the Text. View previously put down (and given id of txt. Name)

Magnified one can see the left of the Edit. Text connected to the right

Magnified one can see the left of the Edit. Text connected to the right of the Text. View

Seen in Text

Seen in Text

Because the Edit. Text in the “first row” takes up more space vertically, the

Because the Edit. Text in the “first row” takes up more space vertically, the next Text. View’s top should be constrained to its bottom.

Text version (second Text. View)

Text version (second Text. View)