介绍

Android 平台提供两种动画系统:Property Animation(Android 3.0引入)和View Animation。这两种动画都可供选择,但是Property Animation是首选,因为它更灵活并且提供更强大的功能。除此之外,你还可以使用Drawable Animation,它允许你加载一系列图片资源并且按照指定的顺序一帧一帧的播放。
Property Animation
Introduced in Android 3.0 (API level 11), the property animation system lets you animate properties of any object, including ones that are not rendered to the screen. The system is extensible and lets you animate properties of custom types as well.
译文:在Android 3.0( API 11)被引入,Property Animation让你可以让任何对象做动画,包括那些没有被渲染到屏幕上的对象。Property Animation 是可扩展的,同时支持对象的自定义属性类型动画。
View Animation
View Animation is the older system and can only be used for Views. It is relatively easy to setup and offers enough capabilities to meet many application's needs.
译文:View Animation 是旧的动画系统并且只能使用在View对象上。它使用比较简单,同时提供足够的动画功能来满足许多应用的需要。
Drawable Animation
Drawable animation involves displaying Drawable resources one after another, like a roll of film. This method of animation is useful if you want to animate things that are easier to represent with Drawable resources, such as a progression of bitmaps.

Drawable animation 一张接一张的去显示一系列图片资源,像一卷电影胶卷。

Android property animation 只有在Android 3.0(API 11)以上版本可用,不过好在已经有开源大神帮我们解决这个问题了。这个项目就是NineOldAndroids

NineOldAndroids将Honeycomb animation API 移植到了整个Android Version平台,使得ValueAnimator、ObjectAnimator等Honeycomb animation API 能不改一行代码,只修改import的包名就完全兼容到新的api。

Usage

如果你熟悉Honeycomb animation API 的话,那么使用就非常简单了,只需要将import android.animation.ObjectAnimator替换为 com.nineoldandroids.animation.ObjectAnimator 即可。

NineOldAndroids 库几乎完全兼容最新的Android 3.0 Property Animation API

 
1
2
3
4
5
6
7
8
9
10
11
12
AnimatorSet set = new AnimatorSet(); 
set.playTogether( 
    ObjectAnimator.ofFloat(myView, "rotationX"0360), 
    ObjectAnimator.ofFloat(myView, "rotationY"0180), 
    ObjectAnimator.ofFloat(myView, "rotation"0, -90), 
    ObjectAnimator.ofFloat(myView, "translationX"090), 
    ObjectAnimator.ofFloat(myView, "translationY"090), 
    ObjectAnimator.ofFloat(myView, "scaleX"11.5f), 
    ObjectAnimator.ofFloat(myView, "scaleY"10.5f), 
    ObjectAnimator.ofFloat(myView, "alpha"10.25f, 1
); 
set.setDuration(5 1000).start();

 

最新文章

  1. spring定时器,定时器一次执行两次的问题
  2. C#图片处理常见方法性能比较
  3. 2016年Java服务器端开发面试总结
  4. 转载:align
  5. Office——EXCEL 打开自动修改 关闭自动保存
  6. 安卓虚拟机启动失败intel haxm未安装
  7. 初窥struts2(二)OGNL表达式
  8. 部分和问题 nyoj
  9. ubuntu amd64 的锐捷连接解决办法---武汉大学
  10. Chapter 5 Blood Type——15
  11. Spark 学习笔记
  12. TODO:BGP 建立过程
  13. 今天我得鼓吹一波 Kotlin
  14. Codeblocks 常用快捷键
  15. ARM总线架构
  16. SQL Server跨服务器查询的实现方法,OpenDataSource
  17. mark CodeGenerator
  18. Androd Toolbar 的简单使用(转)
  19. 转!!mysql 字段 is not null 和 字段 !=null
  20. (一)ElasticSearch-入门

热门文章

  1. iOS 添加功能引导图
  2. 【MyBean-开源框架】进行简单的逻辑插件(演示在控制台中应用)
  3. Java获取某个月的天数
  4. SVN如何切换账号
  5. visio直线交叉相交跨线修改
  6. sql 基础练习 计算7天各个时间点的总和 group by order mysql一次查询多个表
  7. spring c3p0 配置
  8. jetty debug修改 java static 静态变量值不会生效
  9. 三者互ping,PC,虚拟机,uboot,nfs网络文件系统搭建
  10. Android DrawLayout + ListView 的使用(一)