View Animation
View animation has never been more fun in Android 4 and above. With Android 5.0 Lollipop, more fun animations can be done by using the ActivityOptions or ActivityOptionsCompat (in AppCompat).
ViewCompat allows you to animate all sorts of animation types with start delays and other neat stuff. One example that returns a ViewPropertyAnimatorCompat object.
ViewCompat.animate(view).setDuration(1000).scaleYBy(1).scaleXBy(1).start();
View Elevation
We all know that setting elevation is not possible in Android 4.+. You can either apply your own drawable shadow to simulate that effect, or you can use the support library to do the following:
b. In Activity B,
This is what I've used so far. Custom animations can be done using ViewCompat, but it's up to you to explore more. I'm still in the middle of exploring as well. Good luck.
View animation has never been more fun in Android 4 and above. With Android 5.0 Lollipop, more fun animations can be done by using the ActivityOptions or ActivityOptionsCompat (in AppCompat).
ViewCompat allows you to animate all sorts of animation types with start delays and other neat stuff. One example that returns a ViewPropertyAnimatorCompat object.
ViewCompat.animate(view).setDuration(1000).scaleYBy(1).scaleXBy(1).start();
View Elevation
We all know that setting elevation is not possible in Android 4.+. You can either apply your own drawable shadow to simulate that effect, or you can use the support library to do the following:
ViewCompat.setElevation(getResources().getDimensionPixelSize(R.dimen.drawable_elevation));
Activity Transitions
If you wanna animate an item only for the activity transition,
a. In Activity A,
ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(context,
view,
R.string.transition_name
);
ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
b. In activity B,
ViewCompat.setTransitionName(view, getString(R.string.transition_name));
If you wanna animate an item only for the activity transition,
a. In Activity A,
ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(context,
view,
R.string.transition_name
);
ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
b. In activity B,
ViewCompat.setTransitionName(view, getString(R.string.transition_name));
If you wanna animate three things at the same time during activity transitions,
a. In activity A,
Pair<View, String> pair1 = Pair.create(view1, getString(R.string.transition1));
Pair<View, String> pair2 = Pair.create(view2, getString(R.string.transition1));
Pair<View, String> pair1 = Pair.create(view1, getString(R.string.transition1));
Pair<View, String> pair2 = Pair.create(view2, getString(R.string.transition1));
Pair<View, String> pair3 = Pair.create(view3, getString(R.string.transition1));
Pair<View, String>[] pairs = new Pair[]{pair, pair2, pair3};
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, pairs);
ActivityCompat.startActivity(context, intent, options.toBundle());
b. In Activity B,
ViewCompat.setTransitionName(view1, getString(R.string.transition_name));
ViewCompat.setTransitionName(view2, getString(R.string.transition_name));
ViewCompat.setTransitionName(view3, getString(R.string.transition_name));
ViewCompat.setTransitionName(view2, getString(R.string.transition_name));
ViewCompat.setTransitionName(view3, getString(R.string.transition_name));
This is what I've used so far. Custom animations can be done using ViewCompat, but it's up to you to explore more. I'm still in the middle of exploring as well. Good luck.
This comment has been removed by the author.
ReplyDeleteWhen I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.
ReplyDeleteSurya Informatics