Reputation: 861
I am trying to transition an ImageView from an item within my RecyclerView inside a fragment to an Activity. I have declared the following in my
styles.xml
<!-- enable window content transitions -->
<item name="android:windowActivityTransitions">true</item>
<!-- specify enter and exit transitions -->
<!-- options are: explode, slide, fade -->
<item name="android:windowEnterTransition">@transition/change_image_transform</item>
<item name="android:windowExitTransition">@transition/change_image_transform</item>
<!-- specify shared element transitions -->
<item name="android:windowSharedElementEnterTransition">
@transition/change_image_transform
</item>
<item name="android:windowSharedElementExitTransition">
@transition/change_image_transform
</item>
Then in my
Recyclerview Adapter
I am starting the activity using
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
ActivityOptionsCompat options = ActivityOptionsCompat.MakeSceneTransitionAnimation((Activity)Context, pec.View, "profile");
Context.StartActivity(intent, options.ToBundle());
}
I have defined both ImageViews with the
transitionName="profile"
and also have a
transition/change_image_transform.xml
that looks like
<?xml version="1.0" encoding="utf-8" ?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeImageTransform/>
</transitionSet>
There are no errors, just no transition takes place between my item in the recyclerview and the activity.
Upvotes: 0
Views: 532
Reputation: 2027
If you using the MakeSceneTransitionAnimation
you do not need to design the transition in the xml file. Just set <item name="android:windowActivityTransitions">true</item>
is enough.
When you do the imageview transition you should make sure the transition name is same.
I have a demo it should be helpful for you, the view transition from MainActivity to Activity1. You can refer to the project and find the solution.
Upvotes: 1