Reputation: 15615
What I Have
I have set the permission correctly.
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<!-- specify shared element transitions -->
<item name="android:windowSharedElementEnterTransition">
@transition/change_image_transform</item>
<item name="android:windowSharedElementExitTransition">
@transition/change_image_transform</item>
And this is my transition file,
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeImageTransform/>
<changeBounds/>
<changeTransform/>
</transitionSet>
Now, in my master activity, I gave a GridView with image thumbnails.
View photo = (View) list.getChildAt(position).findViewById(R.id.fileThumb);
photo.setTransitionName("photo" + position);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(), Pair.create(photo, photo.getTransitionName()));
Intent intent = new Intent(getActivity(), GalleryActivity.class);
intent.putExtra(Config.GALLERY_EXTRA, position);
getActivity().startActivity(intent, options.toBundle());
In my Detail activity,
I have a ViewPager with a fragments. In the onCreate() of the fragment, I did this.
final PhotoView photoView = new PhotoView(container.getContext());
relativeLayout.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
photoView.setTransitionName("position"+pos);
The animation seems to work on the correct items, but not smoothly. There seems to be a glitch in the animation. However, the exit transition is somewhat smooth. But still not perfect.
What am I doing wrong here?
Upvotes: 2
Views: 1376
Reputation: 365
Are you using the PhotoView library by Chris Banes? If so, it's not yout fault but a bug in the library: https://github.com/chrisbanes/PhotoView/issues/243
Upvotes: 3