共有要素のトランジション アニメーションに奇妙な問題があります (トランジション ライブラリのバグかもしれません)。ターゲット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持っています。共有要素の遷移が正しく定義され、開いたときに正しくアニメーション化されます。imageViewAFragmentBimageViewAFragmentBimageViewA
ただし、コンテナ(ルートコンテナ)にFragmentA追加された場合に備えて機能します。コンテナcontent_frameに追加FragmentAすると、アニメーションがまったく機能しません。content_main
content_secondコンテナにいくつかのビューを追加すると、アニメーションが機能しません。- コンテナーを空のままにしておくと、
content_secondアニメーションが機能しません。 - コンテナーを削除しても、
content_secondアニメーションが機能しません。
両方のフラグメントが同じコンテナーに追加されます (を使用FragmentTransaction.replace)。