动画

The Android framework provides two animation systems: property animation and view animation. Both animation systems are viable options, but the property animation system, in general, is the preferred method to use, because it is more flexible and offers more features. In addition to these two systems, you can utilize Drawable animation, which allows you to load drawable resources and display them one frame after another.

Android Framework 提供了两个动画系统:属性动画和视图动画。它们都提供了可行的选项,但是一般情况下推荐使用属性动画,因为它更加灵活并且提供了更多特性。除了这两种动画系统,还可以利用 Drawable 动画来加载 drawable 资源进行一帧帧的显示。

Property Animation(属性动画)

Android 3.0(API 11)加入,属性动画让你可以给对象的属性进行 key 动画,即使是在屏幕上没渲染出来的。这套系统是可扩展的,让你也可以对自定义类型的属性进行 key 动画。

类继承关系

  • Animator
    • AnimatorSet
    • ValueAnimator
    • ObjectAnimator
    • TimeAnimator

    setStartDelay() 设置延迟播放动画

Interpolator 差值器 与 TypeEvaluator 估值器区别

The ValueAnimator encapsulates a TimeInterpolator, which defines animation interpolation, and a TypeEvaluator, which defines how to calculate values for the property being animated. For example, in Figure 2, the TimeInterpolator used would be AccelerateDecelerateInterpolator and the TypeEvaluator would be IntEvaluator.

属性动画的核心类:ValueAnimator 封装了一个 TimeInterpolator 和一个 TypeEvaluator,TimeInterpolator 规定了动画的差值,TypeEvaluator 定义了如何计算要进行动画的属性的值。
一个针对时间的变化,一个针对值得变化。

To start an animation, create a ValueAnimator and give it the starting and ending values for the property that you want to animate, along with the duration of the animation. When you call start() the animation begins. During the whole animation, the ValueAnimator calculates an elapsed fraction between 0 and 1, based on the duration of the animation and how much time has elapsed. The elapsed fraction represents the percentage of time that the animation has completed, 0 meaning 0% and 1 meaning 100%. For example, in Figure 1, the elapsed fraction at t = 10 ms would be .25 because the total duration is t = 40 ms.
[elapsed fraction 过去的时间分数(时间因子)]

自定义 Interpolator 与 TypeEvaluator

Interpolator 差值器

当你没有为动画设置插值器时,系统默认会帮你设置加减速插值器AccelerateDecelerateInterpolator

自定义 Interpolator ,继承 Interpolator,重写 public float getInterpolation(float input) 方法,对返回值做处理。
这里的 input 参数是[0,1]的数,0 表示开始,1 表示结束,是系统根据设置的动画时间计算出来的,从0匀速到1。

TypeEvaluator 估值器

自定义TypeEvaluator需要重写evaluate()方法,计算对象的属性值并将其封装成一个新对象返回

重写:
public T evaluate(float fraction, T startValue, T endValue);

使用XML编写动画

参考

Animating Layout Changes to ViewGroups

Specifying Keyframes

Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
Keyframe kf1 = Keyframe.ofFloat(.5f, 360f);
Keyframe kf2 = Keyframe.ofFloat(1f, 0f);
PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2);
ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(target, pvhRotation)
rotationAnim.setDuration(5000ms);

更多参考 MultiPropertyAnimation.java

Animating with ViewPropertyAnimator

Multiple ObjectAnimator objects

ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 50f);
ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 100f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();

One ObjectAnimator

PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 50f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 100f);
ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start();

ViewPropertyAnimator

myView.animate().x(50f).y(100f);

如果只是对 View 的一个或两个属性进行动画,使用 ObjectAnimator 就可以完成,如果想要对 View 的多个属性同时进行动画,使用 ViewPropertyAnimator 会更方便。

更多参考 blog post

View Animation(视图动画)

视图动画是一款老的动画系统,只能给 View 视图 key 动画。使用简单并且提供了足够的功能来满足一般应用的需要。

类继承关系

  • Animation
    • AlphaAnimation
    • TranslateAnimation
    • ScaleAnimation
    • RotateAnimation
    • AnimationSet

Drawable Animation(帧动画)

drawable 动画涉及一个接一个的显示 drawable 资源文件,就像播放电影。这种动画方式在你需要使用 Drawable 资源文件来做动画的情况下是非常有用的。

郭霖属性动画:http://blog.csdn.net/guolin_blog/article/details/43536355#t6
浅析Android动画 http://www.cnblogs.com/wondertwo/p/5295976.html

Android 动画相关推荐

  1. Android动画效果translate、scale、alpha、rotate详解

    动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面 ...

  2. android jason动画,Android 动画之Lottie动画使用

    Android 动画之Lottie动画使用 一:简介 Lottie是Airbnb开源的一套跨平台的完整解决方案,设计师只需要使用After Effects(简称AE)设计动画之后,使用Lottic提供 ...

  3. android动画的实现原理,Android动画的实现原理 .

    1.动画运行模式 独行模式 中断模式 2.Animation类 每个动画都重载了父类的applyTransformation方法这个方法的主要作用是把一些属性组装成一个Transformation类, ...

  4. Android动画曲线库AndroidEasingFunctions

    Android动画曲线库AndroidEasingFunctions AndroidEasingFunction是基于Easing Function(缓动函数)的Android动画曲线库.它提供了九大 ...

  5. android 动画引擎,一个使用openGL渲染的炫丽Android动画库

    这是一个 android 动画特效库 可以实现各种炫酷动画. github地址: ht t ps:// gith  u b.co m/g pl ib s/an dro id- ma gic-s ur ...

  6. Android 动画分析学习笔记

    一:分类: Android动画分三种:view动画(对场景中的对象不断做图像变换<平移,缩放,旋转,透明度>).帧动画(顺序播放一系列图像产生动画效果).属性动画(动态改变对象属性). 二 ...

  7. Android动画之Tween动画实战

    Android动画分为Tween动画和Frame动画,上一节通过一个实例介绍了Frame动画,本节将介绍Tween动画.Tween可以把对象进行缩小.放大.旋转和渐变等操作. Tween动画有四个主要 ...

  8. Android动画 详解(一 补间动画)

    2019独角兽企业重金招聘Python工程师标准>>> 打算整理下 android动画方面的知识,嗯  开始 一.android补间动画 分为四大类 alpha(透明度渐变).sca ...

  9. Android 动画之ScaleAnimation应用详解

    本节讲解ScaleAnimation 动画在应用中的实现,有需要的朋友可以参考下 android中提供了4中动画: AlphaAnimation 透明度动画效果 ScaleAnimation 缩放动画 ...

  10. Android动画开发——Animation动画效果

    动画类型 Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面 ...

最新文章

  1. PHP5 mysqli 教程
  2. 永远不会执行的cron表达式
  3. 大话数据结构 :排序
  4. 第二百四十六节,Bootstrap弹出框和警告框插件
  5. 前端学习(3067):vue+element今日头条管理-element里面的image组件
  6. CCNP-第十一篇-BGP(三)(精髓篇)
  7. leetcode374. 猜数字大小
  8. 保存blob到本地_用12行代码提取浏览器自动保存的密码
  9. powershell快捷键_关于powershell的知识你知道多少呢
  10. 价值5000元的报表分享
  11. W25Q64 Flash芯片原理与应用方案(含W25Q64中文数据手册)
  12. python生成三对角矩阵_使用Python的三对角矩阵
  13. qq飞车手游服务器维护中,QQ飞车手游3月28日停机维护到几点_QQ飞车手游3.28停机维护时间_玩游戏网...
  14. OpenNESS Release 21.03
  15. Latex下载和使用
  16. 低代码开发平台+KM知识文档管理系统搭配的好处
  17. 【高等数学】二重积分交换积分次序,反三角函数主值区间选择
  18. mysql hash索引 btree索引_HASH索引做等值查询会很快,BTree索引做范围查询比较快...
  19. 13 个非常有用的 Python 代码片段,建议收藏
  20. [渝粤教育] 西南科技大学 机电一体化技术 在线考试复习资料2021版

热门文章

  1. MATLAB实现将图片转化为gif格式的动画
  2. DBS3900组网方式学习
  3. iOS的就业前景与广州iOS培训机构
  4. 对浏览器内核的理解和常见的浏览器内核
  5. 2201: 逆置线性表(线性表)
  6. JackKnife开发专题-方便快捷的IOC框架
  7. 虚数到底有什么意义?从 i 说起
  8. Linux网络之连接跟踪(conntrack)
  9. 利用TUN创建虚拟网络
  10. 什么是堡垒机?堡垒机有何优势?