无法为CardView Android Transition创建图层

科什

我在使用Android TransitionAPI时遇到了一个非常奇怪的问题我有sharedElement一个ImageView,我让操作系统处理Transition这两个元素之间。但是我有这个奇怪的问题,如下面gif所示
一个共享元素

如您所见,elementanimating唯一的AvatarView,但是onBackPressed使用此日志使应用程序崩溃

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)

开始的代码 Activity

第一的 Layout

<com.fastaccess.ui.widgets.AvatarLayout
            android:id="@+id/avatarLayout"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:transitionName="@string/image_transition"/>   

第二 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"/> 

这就是我开始的方式 Transition

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
sharedElement, ViewHelper.getTransitionName(sharedElement));
activity.startActivity(intent, options.toBundle());

此后没有多余的代码,除了我打电话 supportFinishAfterTransition

这是另一个gif,但没有SharedElement Transition&则可以正常工作。在此处输入图片说明

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.

Kosh

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

实际上,这CardView是真正的原因,而且时间不长,TextView我将CardView更改LinearLayout为我的行项目的根元素,并删除了我在上面所做的所有变通办法,并且一切似乎都正常进行。我不知道为什么会导致此问题,我希望有人可以提供帮助并详细说明为什么大型CardView问题会导致此问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法创建GeoJSON图层

无法为Android Google Maps创建ClusterManager

Android无法导入RecyclerView和CardView

xamarin android构建错误:“无法为类创建JavaTypeInfo”

无法在Android上为Azure AD创建SingleAccountPublicClientApplication

在android中通过cardview创建视图

如何在Android中动态创建CardView

如何在Android中创建循环CardView?

创建基于项目计数android的cardview列表

OpenCV:无法创建类型为“ Shape”的图层“ flatten_1 / Shape”

Geotools OSM Tile图层无法加载图像,无法创建ImageInputStream

无法在 Visual Studio for Mac 中为 Android 7.0+ 创建 Android 虚拟设备?

无法创建目录:Android

无法使android创建通知

无法创建WebView Android

为动画创建另一个图层类

Android 不会在 CardView 中将视图显示为线

在Android中将CardView显示为对话框

android - 为每个 cardview 获取有限的 json 数组

当API <21时,Android CardView setBackground为BitmapDrawable

如何在android中为CardView制作透明背景?

使用图层列表为 android 绘制图像

Android中的Mapbox-GEOTiff栅格图层周围为黑色

无法使Android支持V7 CardView库正常工作

CardView错误:无法解析类android.support.v7.widget.CardView

将 androidx 生命周期从 2.2.0-alpha03 更新为 alpha04 后,“androidx.transition.TransitionSet 无法转换为 android.transition.Transition”

无法为 cashape 图层设置图像

无法在Android平台上使用InputStream为Bluetooth套接字创建ObjectInputStream

更新后,Android Studio无法为锁定文件创建父目录