Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Transition.captureStartValues and Transition.captureEndValues have the same View with same attributes?

I have a custom Transition used in shared elements between my two Activities.

My transition doesn't work because the TransitionValues parameters has the same View with same attributes in both methods, captureStartValues and captureEndValues. So, my transition doesn't have what to do once the start and end values are the same.

Why is this happens?

like image 467
André Mion Avatar asked Apr 28 '16 12:04

André Mion


1 Answers

In my case i wanted to transition between two element's background drawable. After a lot of digging i ended getting to the realization that the view delivered to the onCaptureStartValues method is not the actual view from the first activity but rather a representation of it created in the second activity from a parcel passed down by the transition framework.

This is counter intuitive but eventually lead me to the following article which have an informative example on how to accomplish what you're after.

https://medium.com/@belokon.roman/custom-transitions-in-android-f8949870bd63

In general you use SharedElementCallback to inject custom properties into your transition object. I really hope this kind of behavior will change in the future as it feels hack-ish.

like image 91
Liran Cohen Avatar answered Sep 28 '22 07:09

Liran Cohen