Reputation: 6334
I'm having a really weird issue with Android Transition
API. I have a sharedElement
an ImageView
that I let the OS handle the Transition
between these two elements. however I'm having this weird issue as showing in the gif below
the only element
that I'm animating
is the AvatarView
as you can see, however onBackPressed
crash the app with this log
java.lang.IllegalStateException: Unable to create layer for CardView
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
The code that starts the Activity
first Layout
<com.fastaccess.ui.widgets.AvatarLayout
android:id="@+id/avatarLayout"
android:layout_width="48dp"
android:layout_height="48dp"
android:transitionName="@string/image_transition"/>
second Layout
<com.fastaccess.ui.widgets.AvatarLayout
android:id="@+id/avatarLayout"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="top"
android:transitionName="@string/image_transition"/>
And here is how I start the Transition
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
sharedElement, ViewHelper.getTransitionName(sharedElement));
activity.startActivity(intent, options.toBundle());
No more fancy code after this, except I'm calling supportFinishAfterTransition
Here is another gif but without SharedElement Transition
& it does work fine.
To be honest the Crash log does not tell much, but i can confirm its due to the Comment TextView
is being Large even tho it has nothing to do with the SharedElement
but it seems it is the cause to the Crash as per my tests.
It'll be great if anyone has encounter this before and found a way to fix it as i gave up.
Any suggestions will be appreciated.
Upvotes: 1
Views: 2767
Reputation: 6334
First Fix Attempting:
setting android:transitionGroup="false"
on the RowItem
rootLayout
itself as if i did set it on the ViewPager
or on the RecyclerView
the same crash will happen.Another important step was returning false
on hasOverlappingRendering()
from the custom TextView
class. but this causes the ExitTransition
to have a flickery background color Another Weird issue I'll be digging more on this & won't accept this answer until i find a solution to the flickery background or someone else has a different approach to fix this.
Edit
The weird background is actually the CardView
itself that holds the CommentTextView
.
Edit
Actually, the CardView
is the actual cause & not the long TextView
I'v changed the CardView to LinearLayout
as the root element of my row items and removed all the workarounds i did above and everything seems to be working fine. I'v no clue why would it cause the issue, I'm hopping someone could actually help & elaborate on why large CardView
would cause this issue.
Upvotes: 2