Glitch when animating nested views in a shared element Activity transition?

后端 未结 1 673
后悔当初
后悔当初 2020-12-30 07:47

I\'ve been messing around with the new APIs in Android 5.0 and have been trying to figure out whether or not it is possible to animate both a ViewGroup and one

相关标签:
1条回答
  • 2020-12-30 08:07

    Yes, you can transition a group and its contents separately. But you just found a bug that will be fixed in L MR1.

    It appears that this is not well supported in L. I recommend that you make the shared elements siblings in the second Activity:

    <FrameLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/dark_gray"
            android:transitionName="outer_box"/>
    
        <RelativeLayout
            android:id="@+id/outer_box"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <View
                android:id="@+id/inner_box"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_marginLeft="50dp"
                android:layout_marginTop="50dp"
                android:background="@color/red"
                android:transitionName="inner_box" />
        </RelativeLayout>
    </FrameLayout>
    
    0 讨论(0)
提交回复
热议问题