Buckstabue
Buckstabue

Reputation: 303

Hide a view when a dependent view is hidden in ConstraintLayout

Is it possible in ContraintLayout to hide/show a view when a dependent view is gone/visible?
Obviously it's possible by using CoordinatorLayout with a custom behavior or by using an wrapped layout, however the mentioned approaches involve additional layouts. I would like to see such an approach that doesn't introduce additional layouts

Upvotes: 0

Views: 1532

Answers (2)

Cheticamp
Cheticamp

Reputation: 62841

You should be able to group the views together using the new "group" feature of ConstraintLayout 1.1.x. See this posting on Medium.

Groups, like the Guidelines, are widgets with size 0. But Group helps to apply some action to a set of widgets. The most common case, is to control a visibility of a collection of widgets.

Upvotes: 1

Karim
Karim

Reputation: 322

You can do this programmatically.

When you set the vivisiblity of a compounant in your code, change the visibility value of the dependent view.

Upvotes: 0

Related Questions