Android使用共享元素实现转场动画 错误:Unable to create layer for XXXLayout

java.lang.IllegalStateException: Unable to create layer for FrameLayout, size 720x20213 exceeds max size 8192
  <androidx.core.widget.NestedScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:transitionGroup="true"
        app:layout_constraintBottom_toTopOf="@+id/layout_shine"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/img_bg"
                android:layout_width="0dp"
                android:layout_height="180dp"
                android:scaleType="fitXY"
                android:transitionName="@string/app_name"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/txt_date"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:paddingStart="16dp"
                android:paddingTop="14dp"
                android:paddingEnd="16dp"
                android:paddingBottom="14dp"
                android:textColor="@color/font_color1"
                android:textSize="16sp"
                android:textStyle="bold"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/img_bg"
                tools:text="苹果山药小米粥、山药豆腐蛋黄粥" />

            <FrameLayout
                android:id="@+id/layout_content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="8dp"
                android:background="@color/white"
                android:minHeight="300dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/txt_date">

                <WebView
                    android:id="@+id/web_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:scrollbars="none"/>
            </FrameLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.core.widget.NestedScrollView>

在共享元素实现转场动画,Transition group 设置为true,让我们可以将ViewGroup作为一个整体来变换

最后的解决方案是,在最外边的ScrollView加上这一句话

android:transitionGroup="true"

问题 – A>ActivityOptionsCompat.makeSceneTransitionAnimation>B>onBackPressed()出错.
从*上得到的答案是:
The Fade transition will use hardware layers when your view does has “hasOverlappingRendering()” return true. This was done for performance. You must have many views all fading out separately.

You have a couple options. One is for your views to have hasOverlappingRendering return false. This may not be possible in all cases, but it may be enough to solve your problem. Remember that this means that the contained views should not overlap!

The second is to transition fewer views separately. You can do this by setting android:transitionGroup=“true” on ViewGroups that should be faded out together. For example, if you have a ListView with no background, you’ll end up transitioning each element separately. Instead, you can set the ListView’s transitionGroup property to true and then they’ll transition together.解决了.

上一篇:unable to read TLD "META-INF/c.tld" jstl1.2.jar


下一篇:[转] Linux 最大进程数, unable to create new native thread问题