如何在android中单击显示圆圈动画

时间:2016-12-27 15:43:17

标签: android material-design

我是Android的新手,阅读Material Design我正在寻找如何设计像这个动画一样的动画

enter image description here

1 个答案:

答案 0 :(得分:1)

此动画在Android API版本21上提供。From the documentation

使用ViewAnimationUtils.createCircularReveal()方法可以设置裁剪圆的动画以显示或隐藏视图。

// previously invisible view
View myView = findViewById(R.id.my_view);

// get the center for the clipping circle
int cx = myView.getWidth() / 2;
int cy = myView.getHeight() / 2;

// get the final radius for the clipping circle
float finalRadius = (float) Math.hypot(cx, cy);

// create the animator for this view (the start radius is zero)
Animator anim =
    ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);

// make the view visible and start the animation
myView.setVisibility(View.VISIBLE);
anim.start();