Skip to content

Instantly share code, notes, and snippets.

Last active Aug 6, 2019
What would you like to do?
Hack for circular reveal animation that emulates linear reveal
* 'Hack' to emulate a linear reveal using circular reveal from `ViewAnimationUtils`
* @param view to reveal
void revealView(View view) {
int cx = view.getMeasuredWidth() * 2;
int cy = view.getMeasuredHeight() / 2;
int finalRadius = (int) Math.hypot(view.getWidth()*2, view.getHeight());
Animator anim;
// for reveal
anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
// for hiding
// anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, finalRadius, 0);
// Note that the 'reveal' time taken in by the extra empty space needs to be factored in.
// You could probably get around this by creating your own interpolator,
// but in which case, you might as well just create your own reveal animation.
//The following worked for the reveal
//anim.setInterpolator(PathInterpolatorCompat.create((float)0.000, (float)0.585, (float)0.005, (float)1.270));
// make the view visible and start the animation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment