揭露动画ViewAnimationUtils.createCircularReveal()
来源:互联网 发布:硬盘坏了恢复数据 编辑:程序博客网 时间:2024/05/18 01:02
当您显示或隐藏一组 UI 元素时,揭露动画可为用户提供视觉连续性。ViewAnimationUtils.createCircularReveal() 方法让您能够为裁剪区域添加动画以揭露或隐藏视图。
应用ViewAnimationUtils.createCircularReveal()方法可以去创建一个RevealAnimator动画。
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>.动画开始的中心点X * @param centerY The y coordinate of the center of the animating circle, relative to * <code>view</code>.动画开始的中心点Y * @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); }
实例代码在onCreate方法中执行动画,控件的宽高还没有计算出来,调用view的post方法。
<ImageView android:background="@color/colorPrimary" android:id="@+id/iv_reveal" android:layout_width="150dp" android:layout_height="150dp" android:layout_gravity="center_horizontal" android:layout_marginTop=“100dp"/>
final ImageView ivReveal = (ImageView) findViewById(R.id.iv_reveal);ivReveal.post(new Runnable() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public void run() { //隐藏 Animator animation = ViewAnimationUtils.createCircularReveal(ivReveal, ivReveal.getWidth() / 2, ivReveal.getHeight() / 2, ivReveal.getWidth() / 2, 0); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.setDuration(1500).start(); animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); ivReveal.setVisibility(View.INVISIBLE); } });// //显示// Animator animation = ViewAnimationUtils.createCircularReveal(ivReveal, 0,// 0, 0 ,ivReveal.getHeight()/2);// animation.setInterpolator(new AccelerateInterpolator());// animation.setDuration(1500).start(); } });
RevealAnimator和之前的动画使用没什么区别,同样可以设置监听器和加速器来实现各种各样的特效。这些效果常用在视图的添加,删除,状态,大小改变的时候。
阅读全文
0 0
- 揭露动画ViewAnimationUtils.createCircularReveal()
- 揭露动画—ViewAnimationUtils.createCircularReveal
- 杂货铺(RecyclerView,SpannableString,ViewAnimationUtils.createCircularReveal()动画)
- Android开发 之 揭露动画
- Android Activity转场 -- 揭露动画
- Android Reveal Animation(揭露动画)实现
- Android CircularReveal揭露动画三种实现
- Android 创建CircularReveal揭露动画的实现
- 一个揭露动画的的折线图
- ViewAnimationUtils的学习记录
- ViewAnimationUtils初体验
- ViewAnimationUtils的使用详解
- Material Design之定制动画--触摸反馈,循环揭露,转场动画,共享元素和曲线运动
- Android动画学习(六)之View揭露效果和SurfaceView实现动画
- Android 使用Circular Reveal为你的应用添加揭露动画效果
- android仿美团底部导航栏的点击效果——揭露动画
- 揭露男人
- Android 5.0特新中ViewAnimationUtils的使用
- Servlet工作原理解析
- Zookeeper实例原生API--异步获取子节点列表
- Class 装载系统
- Java对象作用域
- mysql安装jdbc驱动
- 揭露动画ViewAnimationUtils.createCircularReveal()
- 由于IE对URL编码问题处理不当带来的XSS的PoC
- 计算机视觉资料
- Restful
- Java反射
- Zookeeper实例原生API--同步获取节点数据
- [HAOI2017]新型城市化
- 简单支持unity同一个项目多开的方式
- 状态栏、沉浸式状态栏