Home » Android » Android transition animation API 19 and above – Stack Overflow

Android transition animation API 19 and above – Stack Overflow

Posted by: admin February 20, 2020 Leave a comment

Questions:

I’m quite new to animation transition. I want to add an animation in the home screen. I don’t know which way to go, is Lottie fit for this or official android libraries.
The animation take about 2-3 seconds and should animate every time I go to that specific screen. Please help, some explanations would be great Here’s some screenshots:
enter image description here

enter image description here

enter image description here

Answers:

You can use ObjectAnimator and AnimatorSet.
Translate that blocks to bottom in order and with some delay.
The code you need is something like that:

ObjectAnimator translateAnimator1 = ObjectAnimator.ofFloat(view1, "translationY", 0, 500).setDuration(2500);
ObjectAnimator translateAnimator2 = ObjectAnimator.ofFloat(view2, "translationY", 0, 500).setDuration(2500);
translateAnimator2.setStartDelay(500);
ObjectAnimator translateAnimator3 = ObjectAnimator.ofFloat(view3, "translationY", 0, 500).setDuration(2500);
translateAnimator3.setStartDelay(1000);

AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(translateAnimator1).with(translateAnimator2).with(translateAnimator3);
animatorSet.start();

ObjectAnimator and AnimatorSet has some extra properties like setRepeatCount etc. that maybe useful.