Android: unable to get general item transition for working with Google Maps fragment

I am trying to get a snippet of Google Maps to save between two actions. I don’t know how to make the stubborn part, but I definitely want the Map to appear in both actions. To make a general transition of an element, I gave the fragments the same transition name. I also enabled Window Transitions, and I started Activity B as follows:

ActivityOptionsCompat options = ActivityOptionsCompat. makeSceneTransitionAnimation(this, map, getString(R.string.map)); startActivity(i, options.toBundle()); 

But for my life I can’t get this transition to work. Any ideas on what I can do wrong?

Action A:

 <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:transitionName="@string/map" android:layout_below="@id/toolbar_map_activity" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.gyang.android.MapActivity" class="com.google.android.gms.maps.SupportMapFragment"/> 

Activity B:

  <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:transitionName="@string/map" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_below="@id/spacer_between_logo_and_map" android:layout_width="200dp" android:layout_height="200dp" tools:context="com.example.gyang.android.MapActivity" class="com.google.android.gms.maps.SupportMapFragment"/> 
+6
source share

All Articles