rp做网站原型要缩小尺寸吗,做护肤品好的网站,深圳网站设计公司哪个好,潍坊网站建设推广报价在Android系统中提供了一种圆形的揭露动画#xff0c;具体表现为一个view以圆形的形式展开、揭示。所谓揭露动画#xff0c;就是一种用于 View 之间#xff0c;甚至界面之间的特殊过渡动画效果。通过ViewAnimationUtils.createCircularReveal方法可以创建一个RevealAnimator…在Android系统中提供了一种圆形的揭露动画具体表现为一个view以圆形的形式展开、揭示。所谓揭露动画就是一种用于 View 之间甚至界面之间的特殊过渡动画效果。通过ViewAnimationUtils.createCircularReveal方法可以创建一个RevealAnimator动画代码如下所示ViewAnimationUtils.createCircularReveal(view,x,//动画开始中心点Xy,//动画开始中心点YstartR,//开始半径endR);//结束半径如上各参数的意思已做了注释。接下来通过一个demo来更好的理解它的用法和效果首先定义一个布局文件显示两张图片android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:gravitycenterandroid:orientationverticalandroid:idid/img_1android:layout_width100dpandroid:layout_height100dpandroid:srcdrawable/test /android:idid/img_2android:layout_width100dpandroid:layout_height100dpandroid:layout_marginTop30dpandroid:srcdrawable/test /然后为这两张图片添加点击事件public void onViewClicked2(View view) {switch (view.getId()) {case R.id.img_1:Animator animator ViewAnimationUtils.createCircularReveal(img1,img1.getWidth() / 2,//动画开始中心点Ximg1.getHeight() / 2,//动画开始中心点Y0,//开始半径img1.getWidth());//结束半径animator.setInterpolator(new AccelerateDecelerateInterpolator());animator.setDuration(1500);animator.start();break;case R.id.img_2:Animator animator2 ViewAnimationUtils.createCircularReveal(img2,0,0,0,(float) Math.hypot(img2.getWidth(), img2.getHeight()));//根号下x的平方y的平方animator2.setInterpolator(new AccelerateDecelerateInterpolator());animator2.setDuration(1500);animator2.start();break;}}运行后点击图片我们可以看到如下效果初始效果点击第一张图点击第二张图我们可以根据自己需要的效果来设置动画开始的中心点以及开始和结束的半径来实现我们想要的效果。不光如此我们还可以为activity的根部局设置揭露动画来实现activity的转场动画。在新activity的onCreate方法中设置llContent.post(new Runnable() {Overridepublic void run() {if (Build.VERSION.SDK_INT Build.VERSION_CODES.LOLLIPOP) {Animator animator createCircularReveal(llContent,llContent.getWidth()/2,llContent.getHeight()/2,0, (float) Math.hypot(llContent.getWidth(),llContent.getHeight()),2000);animator.start();}}});其中llcontent是根部局动画开始中心是布局的中心动画开始半径是0结束半径是对角线长度的一半动画时间设置的是2秒这样在进入activity的时候就可以看到整个布局是由中心向外以圆形的方式展开的。值得注意的是该动画效果是从Android5.X开始添加的在使用时我们要注意版本的控制。乐潮信息www.leco-tec.com原创引用请表明出处