我有一个共享元素过渡动画的奇怪问题(可能是过渡库中的错误)。目标Android version
是5.0
。
这是我的布局:
<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>
我有 2 个片段(FragmentA
和FragmentB
)。FragmentA
有imageViewA
并且FragmentB
有imageViewA
更大的尺寸。共享元素转换定义正确,FragmentB
打开时imageViewA
动画正确。
但它仅在FragmentA
添加到content_frame
容器(根容器)时才起作用。如果我要添加FragmentA
到content_main
容器中 - 动画根本不起作用。
- 如果我向
content_second
容器添加一些视图 - 动画不起作用。 - 如果我将
content_second
容器保持为空 - 动画不起作用。 - 即使我删除
content_second
容器 - 动画也不起作用。
两个片段将被添加到同一个容器中(使用FragmentTransaction.replace
)。