Android Reveal animation in simple steps
The only thing you are going to use is this method.
ViewAnimationUtils.createCircularReveal(layout, centerX, centerY, startRadius, endRadius);
Now, let's break down this method into bits and pieces.
The parameters used are
- layout: which will be animated
- centerX: x- coordinate on the layout
- centerY: y- coordinate on the layout
- startRadius: Should be 0.
- endRadius: Calculate like this. It’s simple math
double endRadius = Math.hypot(layout.getWidth(), layout.getHeight());
And you are done.
Just call this method based on your life choices :)
Bonus
The reverse of the Reveal Animation
Interchange the startRadius and endRadius with each other. ViewAnimationUtils.createCircularReveal(layout, centerX, centerY, startRadius, endRadius);
Note
Since the Transition API was introduced in API 21.
So you will have to add the check condition
if(Build.VERSION.SDK_INT>20) { ViewAnimationUtils.createCircularReveal(layout, centerX, centerY, startRadius, endRadius); }
You can obviously add transition interval, interPolator etc based on your requirements. You can see the full code implementation.
Putting up content takes a lot of time and effort 😓.
👏 clap 👏 If you think you learned something from this article.You can find me on Stackoverflow,Github,and,on Linkedin.
Give feedback and feel free to correct mistakes.