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
To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.
Using an OnClickListener Inside your Activity instance's onCreate() method you need to first find your Button by it's id using findViewById() and then set an OnClickListener for your button and implement the onClick() method so that it starts your new Activity .
Start new Activity by existing Activity on a button clickUsing the "startactivity(Intent intent)" method and "startActivityforResult(Intent intent, requestCode requestCode)" method.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With