Started realization for open images with Shared Elements and animation by this guide.
https://android-developers.googleblog.com/2018/02/continuous-shared-element-transitions.html
But catched an exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
at android.support.transition.TransitionSet.setDuration(TransitionSet.java:196)
at android.support.transition.TransitionSet.setDuration(TransitionSet.java:60)
at android.support.transition.Transition.<init>(Transition.java:278)
at android.support.transition.TransitionSet.<init>(TransitionSet.java:91)
at android.support.transition.TransitionInflater.createTransitionFromXml(TransitionInflater.java:151)
at android.support.transition.TransitionInflater.inflateTransition(TransitionInflater.java:70)
When call
TransitionInflater.from(context).inflateTransition(R.transition.my_transition)
Found nothing on this problem from the Google, that why i post this.
Problem was in duration parameter.
You can fix it like this:
Need to remove duration from xml, and set it after TransitionSet created in code.
val transition = TransitionInflater.from(context).inflateTransition(R.transition.my_transition)
transition.duration = 325
Hope helped someone.
In my case this error was happening because I had imported TransitionInflator from
import android.support.transition.TransitionInflater
While it should be imported from
import android.transition.TransitionInflater
When I fixed the import, the error got resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With