16
Things to note
● One vertical constraint and one horizontal constraint
should be added
● If not, Top left is default
● Only 1 constraint for each side
● No match parent (use 0 dp instead)
Code sample
Constraint Layout
Positioning Attributes
Slide 17
Slide 17 text
Constraint Layout
Bias
Determining which side to bias
17
Placeholders
42
Placeholder view which is ready for other views to
place
Slide 43
Slide 43 text
43
Constraint Layout
Placeholder
PLACEHOLDER
● Empty View ( Placeholder ) with
constraints
● Any view can be swapped into it
dynamically or directly in XML
● TransitionManager helps auto
transitions
Slide 44
Slide 44 text
44
Two use cases
● Transition by placing dynamically
● Template of multi screen support
Constraint Layout
Placeholder
Slide 45
Slide 45 text
45
Constraint Layout
Placeholder
Slide 46
Slide 46 text
46
Constraint Layout
Placeholder
Slide 47
Slide 47 text
47
Constraint Layout
Placeholder
Slide 48
Slide 48 text
Barriers
48
Barrier between views
Slide 49
Slide 49 text
49
Constraint Layout
Barrier
Want to show a view at
the end of two buttons
Slide 50
Slide 50 text
50
Constraint Layout
Placeholder
Slide 51
Slide 51 text
51
Code Sample
Constraint Layout
Placeholder
Slide 52
Slide 52 text
Constraint Sets
52
Animate between two layouts
Slide 53
Slide 53 text
Constraint Layout
Constraint Set
53
1. Create two layouts
2. Clone into two ConstraintSets
3. Apply To ConstraintLayout
Slide 54
Slide 54 text
54
Constraint Layout
Constraint Set
Slide 55
Slide 55 text
55
Things to note
● Should be inside a single constraint layout
● All children must have id
● Does not animate text size
● Views invisible? Must hide some view on initial
layout
Constraint Layout
Constraint Set
Slide 56
Slide 56 text
Constraint Layout
Do’s
● Try Layout Editor
● Groups for visibility control
● Play with Chains instead of weights
● Using Guidelines as keylines
● Basic transitions with Constraint sets
56
Slide 57
Slide 57 text
Constraint Layout
Don’ts
● Do not overuse
● Reduce constraints (esp. in Recyclerview)
● Think twice before using barriers in Recyclerview
● Missing IDs
● Nested constraint layout
57
Slide 58
Slide 58 text
Constraint Layout
2.0
58
What’s new
Slide 59
Slide 59 text
59
Helper Views like Guidelines
● Linear
● Flow ( Flexbox style )
Constraint Layout 2.0
Constraint Helpers
Slide 60
Slide 60 text
Constraint Layout 2,0
Layers
60
● Hide, show, lock elements in editor
● Support transforms
Slide 61
Slide 61 text
Constraint Layout 2.0
Layout Management
61
● Improved layout editor
● Constraint sets via xml ( Constraint states )
● Motion layout + Motion Scene
( Constraint states + Motion Events + Key Frames )