I have a ConstraintLayout with two views A and B that are stacked vertically. I have a third view C which needs to be to the end of both A and B horizontally. At any given point
This can be easily achieved using the new Barriers
feature.
How to use Barriers ?
Barriers are like building a HUUUUGE WALL that "protects" the views mentioned in constraint_referenced_ids
. So, you have to mention which direction it's "supposed to keep out" which in our case is the right (view_c). Just use the barrierDirection
attribute.
Finally, don't forget to make sure that view_c is in the keep out zone (layout_constraintLeft_toRightOf="@+id/barrier1"
).
As this feature is available only in the 1.1.0 beta1 release of ConstraintLayout, don't forget to add this line to your build.gradle file.
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
Hope this helps!