Recently trying to implement Constraint Layout
but I found Barrier
and Guideline
works same. Both works like divider.
Assume you have two TextView
widgets with dynamic heights and you want to place a Button
just below the tallest TextView
:
The ONLY way to implement that directly in the layout is to use a horizontal Barrier
. That Barrier
allows you to specify a constraint based on the height of those two TextView
s. Then you constrain the top of your Button
to the bottom of the horizontal Barrier
.
Assume you want to restrict the above-mentioned TextView
heights to 30% of screen height, no matter the content they have.
To implement that you should add horizontal Guideline
with percentage position and constrain the TextView
bottom to that Guideline
.
The only difference between Barrier
and Guideline
is that Barrier
's position is flexible and always based on the size of multiple UI elements contained within it and Guideline
's position is always fixed.