6

When I click any image or text the activity should start from the position of image or text which is clicked. I tried for

overridingTransition(R.anim.xyz,R.anim.z);

but this is static. I want to start the activity from the image position not from left right or corner of screens

Drunix
  • 3,313
  • 8
  • 28
  • 50
Devyani M
  • 441
  • 1
  • 4
  • 16

1 Answers1

3

Activity Shared Element Transition

Activity Shared Element Transition

Source: https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition

What you need to do is to provide a transition name that both Activites can use to create a transition animation with.

So the ImageView you click in the first activity needs the attribute android:transitionName="your_shared_transition_name" and then you need to set the same attribute for the ImageView in the target Activity too.

To use the shared transition name you need to provide the start intent with a option Bundle like this:

Intent intent = new Intent(this, TargetActivity.class);
ActivityOptionsCompat options = ActivityOptionsCompat.
    makeSceneTransitionAnimation(this, (View)yourImageView, "your_shared_transition_name");
startActivity(intent, options.toBundle());

And to make the Activities support this type of transitions you need to add the attribute android:windowContentTransitions to your Theme

...
 <item name="android:windowContentTransitions">true</item>
...

-follow the linked tutorial above for a more detailed explanation

TouchBoarder
  • 6,422
  • 2
  • 52
  • 60