I am trying to wrap around a new Activity Transition framework in Lollipop . The activity transition works pretty well, and there is basic information here , but the Fragment Transition undocumented, and I can't get it to work. I tried this use case (very common in Android):
case 1: ActA + FragA → ActB + FragB
with sharedElement being an image in FragA and FragB . I did not come up with working code, so I took a step back and tried
Case 2: ActA + FragA → ActB
from sharedElement to FragA and ActB . The animation will not work, I can only see that when I click on the image on FragA, the image disappears, and after the duration of the animation, it appears in ActB. General views outside FragA, but inside ActA (e.g. Toolbar ) are animated correctly.
In this case, sharedImage is an imageView in RecyclerView, maybe the android:transitionName="shared_icon" xml tag android:transitionName="shared_icon" in the xml elements layout doesn't work?
This is my topic:
<item name="android:windowContentTransitions">true</item> <item name="android:windowAllowEnterTransitionOverlap">true</item> <item name="android:windowAllowReturnTransitionOverlap">true</item> <item name="android:fragmentAllowEnterTransitionOverlap">@bool/true_bool</item> <item name="android:fragmentAllowReturnTransitionOverlap">@bool/true_bool</item> <item name="android:windowEnterTransition">@transition/window_transition.xml</item> <item name="android:windowExitTransition">@transition/window_transition.xml</item> <item name="android:fragmentEnterTransition">@transition/window_transition.xml</item> <item name="android:fragmentReturnTransition">@transition/window_transition.xml</item> <item name="android:fragmentReenterTransition">@transition/window_transition.xml</item> <item name="android:windowSharedElementEnterTransition">@transition/shared_elements_transform.xml</item> <item name="android:windowSharedElementExitTransition">@transition/shared_elements_transform.xml</item> <item name="android:fragmentSharedElementEnterTransition">@transition/shared_elements_transform.xml</item> <item name="android:fragmentSharedElementReturnTransition">@transition/shared_elements_transform.xml</item>
window_transition.xml:
<?xml version="1.0" encoding="utf-8"?> <transitionSet xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together" android:duration="@integer/act_transition_duration"> <changeBounds /> <changeTransform /> <changeClipBounds /> <changeImageTransform /> </transitionSet>
shared_element_transition.xml:
<?xml version="1.0" encoding="utf-8"?> <transitionSet xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together" android:duration="@integer/act_transition_duration"> <changeImageTransform /> <changeBounds /> </transitionSet>
android android-5.0-lollipop android-fragments shared-element-transition activity-transition
David corsalini
source share