Lollipop multiple Shared view transition

I am working on creating beautiful transitions in my application. I was able to split one item but failed when I split multiple items. The following code only animates one element out of 3 common ones. I do not know why. It looks like this is due to the last view specified in the layout XML file.

Here's what I did:
In my theme:

<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>

      

In the OnCreate action:

getWindow().setSharedElementExitTransition(TransitionInflater.from(this).inflateTransition(R.transition.change_image_transform));

      

In action Clic listener:

ImageView header = (ImageView) findViewById(R.id.iv_header);
ImageView tv_menu_home = (ImageView) findViewById(R.id.tv_menu_home);
ImageView tv_menu_prefs = (ImageView) findViewById(R.id.tv_menu_prefs);

ActivityOptions optionsCompat = ActivityOptions.makeSceneTransitionAnimation(MainActivity.this
                        ,Pair.create((View)tv_menu_prefs,tv_menu_prefs.getTransitionName())
                        ,Pair.create((View)tv_menu_home,tv_menu_home.getTransitionName())
                        ,Pair.create((View)header,header.getTransitionName())
                );

      

In the change_image_transform.xml file:

<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
    <changeImageTransform />
</transitionSet>

      

In both layouts xml

...
<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_menu_home"
        android:src="@drawable/bouton_home"
        android:contentDescription="@string/hint_accueil_desc"
        android:transitionName="MyTransitionHome"
        />
...
<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_menu_prefs"
        android:src="@drawable/bouton_pref"
        android:contentDescription="@string/hint_preferences_desc"
        android:transitionName="MyTransitionPrefs"
        />
...
<ImageView
    android:id="@+id/iv_header"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/fakeHeader"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:src="@drawable/header"
    android:transitionName="MyTransition" />

      

+3
android android-5.1.1-lollipop android-transitions shared-element-transition


source to share


No one has answered this question yet

Check out similar questions:

782
How do I create a RecyclerView with multiple view types?
50
"RuntimeException: The native font could not be created" when loading the font
fourteen
Blink / flash bluetooth
nine
Is it possible to navigate from a shared item to a view in a RecyclerView?
7
Undo general refund transition to Android Lollipop
3
Content transitions at the top of shared elements in android
2
Wrong overflow menu layout
2
Android - tiled backgrounds sometimes stretch
1
Android - SurfaceView assigned from findViewById (R ...) will not allow access to custom fields
0
Gmail App - Transitions Shared Elements Lollipop



All Articles
Loading...
X
Show
Funny
Dev
Pics