Android 5.0中引入了很多炫酷的动画效果,Circular Reveal便是其中一种。使用起来很简单,但效果却是意想不到的炫酷,让你的app更有逼格。
一、效果
废话不说,下面的gif图中使用Circular Reveal动画实现跳转到搜索页的效果。gif图压缩宽高比失真了,不过效果还在。源码在最下面,可以下载体验下。
二、Circular Reveal介绍
当您显示或隐藏一组 UI 元素时,揭露动画可为用户提供视觉连续性。
ViewAnimationUtils.createCircularReveal()方法让您能够为裁剪区域添加动画以揭露或隐藏视图。
/* @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle, relative to * <code>view</code>. * @param centerY The y coordinate of the center of the animating circle, relative to * <code>view</code>. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { return new RevealAnimator(view, centerX, centerY, startRadius, endRadius); }
ViewAnimationUtils.createCircularReveal()方法所执行的效果,就是将一个View裁剪成圆,然后从圆心逐渐揭露展现视图。
参数 | 参数说明 |
---|---|
view | 要执行动画效果的View |
centerX | 圆心x坐标 |
centerY | 圆心y坐标 |
startRadius | 开始时的圆半径 |
endRadius | 结束时的圆半径 |
三、实现
从上图可以看出,需要揭露展现的View是整个视图的根布局。开始的位置就是
注:相关教程知识阅读请移步到Android开发频道。
新闻热点
疑难解答