Created
July 7, 2015 21:59
-
-
Save keyboardr/572a5eae9f57be286c24 to your computer and use it in GitHub Desktop.
Centered circular reveal animator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@TargetApi(VERSION_CODES.LOLLIPOP) | |
private Animator createCenteredReveal(View view) { | |
// Could optimize by reusing a temporary Rect instead of allocating a new one | |
Rect bounds = new Rect(); | |
view.getDrawingRect(bounds); | |
int centerX = bounds.centerX(); | |
int centerY = bounds.centerY(); | |
int finalRadius = Math.max(bounds.width(), bounds.height()); | |
return ViewAnimationUtils.createCircularReveal(view, centerX, centerY, 0f, finalRadius); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're ok sacrificing a little performance, you can also fix the timing with the following: