Fragment shared element transition not working in nested views

萝らか妹 提交于 2020-01-17 02:32:12

问题


I have a strange problem (maybe it's a bug in transitions library) with shared element transition animations. Target Android version is 5.0.

Here is my layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"                                     xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/root_layout">

        <RelativeLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <!-- The main content view -->
            <FrameLayout
                android:id="@+id/content_main"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                >
            </FrameLayout>

            <!-- The second content view -->
            <FrameLayout
                android:id="@+id/content_second"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                >
            </FrameLayout>

        </RelativeLayout>
</RelativeLayout>

I have 2 fragments (FragmentA and FragmentB). FragmentA has imageViewA and FragmentB has imageViewA with bigger size. Shared element transitions defined correctly and when FragmentB opens imageViewA animated correctly.

But it works just in case when FragmentA is added to content_frame container (root container). If I'm adding FragmentA to content_main container - animation not working at all.

  • If I add to content_second container some view - animation is not working.
  • If I keep content_second container empty - animation is not working.
  • Even if I remove content_second container - animation is not working.

Both fragments would be added to the same container (using FragmentTransaction.replace).

来源:https://stackoverflow.com/questions/29029970/fragment-shared-element-transition-not-working-in-nested-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!