简体   繁体   中英

Animate on scroll using ConstraintLayout and CoordinatorLayout

I'm rewriting an iOS app for Android, and I'm looking to achieve this animation using ConstraintSets and CoordinatorLayout:

http://gph.is/2El97IJ

This droidcon talk gave me the idea that this was doable without using CollapsingToolbarLayout but it seems like transitioning between two ConstraintSets cannot be done in relation to the scroll offset and instead must be animated with a specified duration using an Animator

I'm a bit stumped on where to begin. Is it possible to set a listener that detects every time the scroll offset changes and animate between two ConstraintSets accordingly, or is CollapsingToolbarLayout the only way to achieve those animations?

EDIT:

Is it also possible to get an animation like this using scroll event listeners and updating ConstraintLayout params? We're currently using this approach on iOS

Unfortunatley, at this moment you can't. But in Android studio 2.0 will be Motion Layout. It's in alpha right now. You can read docs and medium article about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM