How To Implement The "parent-to-child" Navigational Transition As Prescribed By Material Design
Solution 1:
One option is to use ActivityOptionsCompat.makeScaleUpAnimation
Activityactivity= getActivity();
Intentintent=newIntent(activity, OtherActivity.class);
Bundleoptions= ActivityOptionsCompat.makeScaleUpAnimation(
sourceView, 0, 0, sourceView.getWidth(), sourceView.getHeight()).toBundle();
ActivityCompat.startActivity(activity, intent, options);
This will cause the new activity to expand vertically and horizontally outwards from your sourceView
Solution 2:
Start an activity with a shared element
To make a screen transition animation between two activities that have a shared element:
Enable window content transitions in your theme. Specify a shared elements transition in your style. Define your transition as an XML resource. Assign a common name to the shared elements in both layouts with the android:transitionName attribute. Use the ActivityOptions.makeSceneTransitionAnimation() method.
// get the element that receives the click eventfinalViewimgContainerView= findViewById(R.id.img_container);
// get the common element for the transition in this activityfinalViewandroidRobotView= findViewById(R.id.image_small);
// define a click listener
imgContainerView.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View view) {
Intentintent=newIntent(this, Activity2.class);
// create the transition animation - the images in the layouts// of both activities are defined with android:transitionName="robot"ActivityOptionsoptions= ActivityOptions
.makeSceneTransitionAnimation(this, androidRobotView, "robot");
// start the new activity
startActivity(intent, options.toBundle());
}
});
For shared dynamic views that you generate in your code, use the View.setTransitionName() method to specify a common element name in both activities.
To reverse the scene transition animation when you finish the second activity, call the Activity.finishAfterTransition() method instead of Activity.finish().
Take from here Customize Activity Transitions
Solution 3:
Hey I think I'm a few weeks late, but I just released a library for building this, inspired by Google Inbox: https://github.com/saket/InboxRecyclerView
Solution 4:
you can animation using below code
Intentintent=newIntent(MainActivity.this, NFCTagInformationActivity.class);
Bundleoptions= ActivityOptionsCompat.makeClipRevealAnimation(
cvTagInfoSmall, 0, 0, cvTagInfoSmall.getWidth(), cvTagInfoSmall.getHeight()).toBundle();
ActivityCompat.startActivity(this, intent, options);
you can use makeScaleUpAnimation
instead of makeClipRevealAnimation
for different view transition animation.
Post a Comment for "How To Implement The "parent-to-child" Navigational Transition As Prescribed By Material Design"