我有一个共享元素过渡动画的奇怪问题(可能是过渡库中的错误)。目标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)。