Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start new activity from the point where it is clicked

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

like image 609
Devyani M Avatar asked Jul 22 '16 05:07

Devyani M


People also ask

How do I intent to start another activity?

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.

How do I get a button to open another activity?

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 .

How do I open an activity from an existing activity?

Start new Activity by existing Activity on a button clickUsing the "startactivity(Intent intent)" method and "startActivityforResult(Intent intent, requestCode requestCode)" method.


1 Answers

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

like image 188
TouchBoarder Avatar answered Oct 01 '22 23:10

TouchBoarder