Relative Guidelines w/ ConstraintLayouts

Make your custom relative constraint to multiple items.

We all know that ConstraintLayout is a huge improvement in the way we develop UI on Android. The constraint properties and component tools it provides are very handy to position the Views all along the Layout. You can even combine them to make items more responsive according to their parent.

Sometimes, you may want to constraint relatively to a View if it is visible, but also to another View or to the parent Layout if the previous View is NOT visible, and so on.

Let’s say I have an icon that I want to constraint to the top parent layout.

Eventually, I also want to show a message above this icon (see below). So, I could constraint the top of the icon to the bottom of the message.

But I don’t really want to separate very much the icon from the top. What I would like is to move the icon a little bit down if the message is visible, but I want to keep the distance relative to the top parent Layout, not the message.