问题
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