I\'m using ConstraintLayout where I will show as below
I would like to hide First
(using gone), and which the view I expect to be as below (whe
An answer has already been given linking to Barriers. I will provide an example of how I've actually implemented it:
This example shows 2 TextViews
either of which can be gone
. The Views are on stacked from top to bottom, so barrierDirection
is set to bottom
. Should you need another direction, just change that line accordingly.
Setting any of the 2 TextViews
to gone
, will result in the Barrier
shifting to the bottom of the other, and if we set both to gone
, it'll just shift up to the element that textView1
's top constraint was referencing, in this case, the parent.
Note: If your
textView1
's top constraint is something else, i.e. it's below another element, the barrier will end up there if both views are set togone
.