Skip to content
Advertisement

Children of CollapsingToolbarLayout with different collapse modes

I would like to create a CollapsingToolbarLayout that contains two views (one below the other – like a LinearLayout manner). The problem is that i would like these views to have different collapse modes – upper one parallax, the other – none.

When I put them in one LinearLayout I can only set the collapse mode to this LinearLayout, so both views behave the same.

I tried putting one view inside a Toolbar and that wat I can achieve two different collapse modes, but I cant get them to be one under the other – I can’t simply set a margin because the upper view has a dynamic height so I would need some kind of anchoring.

Advertisement

Answer

Consider using MotionLayout. All you have to do is define the start and end states (In this case, the start state will have both of them visible, and the end state will have the top one gone with parallax effect).

Advertisement