android常用动画模板
来源:互联网 发布:控油的爽肤水 知乎 编辑:程序博客网 时间:2024/06/04 23:23
总结:使用动画要使用属性动画并且都是兼容低版本的老九包里面的属性动画,所有以老九为核心
一.补间动画:指的是TranslationAnimation,AlpahAnimation,ScaleAnimation,RotateAnimation;
缺点:并没有真正持久改变View的属性,就是说它内部没有一个去记录动画行为的机制;
帧动画:指的是一帧一帧播放的动画实现:通过animation-list来实现,写法如下: <animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:duration="200" android:drawable="@drawable/ic_launcher"/> <item android:duration="200" android:drawable="@drawable/ic_launcher"/> <item android:duration="200" android:drawable="@drawable/ic_launcher"/> </animation-list>二.属性动画(为了解决补间动画的缺点)1.属性动画内部实现:3.0之后view类增加新的用来记录动画行为的属性,如: translationX,translationY; scaleX,scaleY; rotationX,rotationY,rotation; alpha;具体实现的类:ObjectAnimator;问题是:ObjectAnimator只能是3.0之后才有,那么我们如果想让属性动画兼容低版本,那么一般 使用NineOldAnidroid.jar来实现属性动画2.NineOldAnidroid.jar:主要封装了属性动画和View相关的操作类,该类库是JackWharton来写的;用法:ViewPropertyAnimator.animate(text).rotationBy(180) .setDuration(500) .start();3.直接操作view的属性来更改view的形态://比如改变view的初始状态位置view.setTranslationX();view.setRotationX();view.setAlpha();view.setScaleX();//如果想在低版本直接操作view的属性,则用如下方法,上面的方法还是3.0以后的,下面的是老九动画的类ViewHelper.setScaleX(text, 0);4.改变动画的运动轨迹:速度插值器 OvershootInterpolator:超过一点再回来BounceInterpolator:像球落地一样的感觉CycleInterpolator :差值器5.自定义动画逻辑:ValueAnimator //注意:这个还是有老九动画之分,导包 的时候都导老九的 ValueAnimator: 它只是帮我们定义了动画的执行流程,但是没有帮我们实行具体的动画逻辑, 我们需要监听动画的进度,然后在回调方法中进行自定义的动画逻辑; 用法:ValueAnimator animator = ValueAnimator.ofInt(100,1000); //监听动画执行的进度 animator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { int animatedValue = (Integer) animator.getAnimatedValue(); // Log.e("tag", "animatorValue:"+animatedValue); //根据动画值的变化进行我们的动画逻辑 // LayoutParams params = text.getLayoutParams(); // params.height = animatedValue; // text.setLayoutParams(params); text.setText(animatedValue+""); } }); animator.setDuration(1500); animator.setStartDelay(1000); animator.start();
十一、使用属性动画实现动画
// 4.增加炫酷动画// 一开始缩小ViewHelper.setScaleX(holder.getHolderView(), 0.5f);ViewHelper.setScaleY(holder.getHolderView(), 0.5f);// 执行放大动画ViewPropertyAnimator.animate(holder.getHolderView()).scaleX(1f).setDuration(400) .setInterpolator(new OvershootInterpolator()).start();ViewPropertyAnimator.animate(holder.getHolderView()).scaleY(1f).setDuration(400) .setInterpolator(new OvershootInterpolator()).start();
属性动画的高级用法:http://blog.csdn.net/guolin_blog/article/details/43816093
阅读全文
0 0
- android常用动画模板
- Android常用动画
- android常用动画举例
- android 常用动画
- android常用动画
- Android常用动画总结
- Android常用动画ListView动画显示
- Android中常用动画效果
- android之动画常用方法
- Android中常用动画效果
- Android Animation动画常用实现
- Android 常用动画之RotateAnimation
- android常用动画[持续更新]
- Android中常用的动画
- Android常用动画的回顾
- Android动画——Android动画常用API
- Android三种常用动画分享(1)--帧动画
- Android三种常用动画分享(2)--补间动画
- The matching wildcard is strict, but no declaration can be found for element 'aop:aspectj’
- mkimage的用法 (转了一个小哥抄的网上几篇文章)
- java关于数组去重
- 线性回归(Linear Regression)
- liunx7系统centos6.8版本编译安装php7
- android常用动画模板
- 在串口通信开发中实现自动查找串口端口的方法
- 使用Qt5.7.0 VS2015版本生成兼容XP的可执行程序
- 解决redis强制关闭问题
- 支付宝支付遇到的各种坑及解决问题
- 开展全网整合营销推广步骤详解
- 关于tomcat启动时的警告 :maxActive is not used inDBCP2
- 有关iOS定位中的蓝条问题
- git --mixed --soft --hard之间的区别