android / sunflower

A gardening app illustrating Android development best practices with migrating a View-based app to Jetpack Compose.
https://d.android.com/jetpack
Apache License 2.0
17.65k stars 4.7k forks source link

Hero image transition animation #66

Open andhie opened 6 years ago

andhie commented 6 years ago

Doing transition animation to detail activity via the hero image

Work to do: Use ActivityOptionsCompat#makeSceneTransitionAnimation(). for the animation by passing in activity and the imageview. Each list item in Plant adapter should use ViewCompat#setTransitionName() and prefix/suffixed with item position. Both list and detail imageview need to have same transition name. this allows anim to transition backwards when user press back on Detail activity We need to delay anim in detail via supportPostponeEnterTransition() until Glide loads the image and then use supportStartPostponedEnterTransition()

https://developer.android.com/reference/android/support/v4/app/ActivityOptionsCompat.html#makescenetransitionanimation_4 https://developer.android.com/reference/android/support/v4/view/ViewCompat.html#setTransitionName(android.view.View,%20java.lang.String)

tiembo commented 6 years ago

Related to #9

tiembo commented 6 years ago

@andhie now that #9 is resolved and the app is a single activity, the work outlined might need to change a bit.

andhie commented 6 years ago

For normal fragments, we can use setSharedElement on the FragmentTransaction. but in the case of Navigation, i'm not sure how you achieve this. is it supported at this moment?

tiembo commented 6 years ago

@andhie shared element transitions with the Navigation component is in the works: https://issuetracker.google.com/issues/79665225

neiljaywarner commented 6 years ago

nudge. this would be great

tiembo commented 6 years ago

@andhie shared element transitions are now available in Navigation 1.0.0-alpha06, which has been merged via #193

andhie commented 6 years ago

@tiembo i have committed some code in my own repo. in the FragmentNavigator see its adding the Navigator.Extras into the ft.addSharedElement(...) yet its not animating. cant figure out why. https://github.com/andhie/android-sunflower/commit/33d9aa9c6a97bc186aac7455df8981728d8beed4