Android动画的点滴

郭神的三部曲:
Android属性动画完全解析(上),初识属性动画的基本用法

Android的绘图一般重写他的onDraw(Canvas canvas)就可以了
自定义View默认的测量模式是:EXACTLY,也就是说,如果自定义View不重写onMeasure方法的话,就只能使用EXACTLY,View只能相应fill_parent或者是具体值,若想view能够识别wrap_content,则需要我们重写onMeasure方法:

双缓冲实现画板 {先绘制到内存中的一个Bitmap图片(这就是缓冲区)上,直到内存中的Bitmap绘制好之后,再一次性地将Bitmap
绘制到View组件上}
逐帧动画(Frame)跟“放电影”原理一样 <animation-list><item/></animation-list>
代码中创建逐帧动画 先创建AnimationDrawable对象,然后调用addFrame(Drawable frame,int duration) ;每次调用addFrame
就相当于向<animation-list.../>元素中添加一个<item.../>子元素

补间动画(Tween) 只能对UI组件执行动画补间 动画还有一个致命的缺陷,就是它只是改变了View的显示效果而已,
而不会真正去改变View的属性 ,位置不会发生改变
只需要动画开始,结束等“关键帧” ,而动画变化的“中间帧”由系统计算并补齐{透明度,旋转,缩放,位移}

属性动画(增强版补间动画) 几乎可以对任何对象执行动画(不管他是否显示在屏幕上)
,使用属性动画时,系统默认的Interpolator其实就是一个先加速后减速的Interpolator,
对应的实现类就是AccelerateDecelerateInterpolator。

ValueAnimator 对值进行了一个平滑的动画过渡
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
anim.setDuration(300);
anim.start();

ObjectAnimator 直接对任意对象的任意属性进行动画操作的,比如说View的alpha属性。
ObjectAnimator animator = ObjectAnimator.ofFloat(textview, "alpha", 1f, 0f, 1f);
animator.setDuration(5000);
animator.start();

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:valueFrom="1"
android:valueTo="0"
android:valueType="floatType"
android:propertyName="alpha"/>
Animator animator = AnimatorInflater.loadAnimator(context, R.animator.anim_file);
animator.setTarget(view);
animator.start();

//组合动画 scale
ObjectAnimator moveIn = ObjectAnimator.ofFloat(textview, "translationX", -500f, 0f);
ObjectAnimator rotate = ObjectAnimator.ofFloat(textview, "rotation", 0f, 360f);
ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(textview, "alpha", 1f, 0f, 1f);
AnimatorSet animSet = new AnimatorSet();
animSet.play(rotate).with(fadeInOut).after(moveIn);
animSet.setDuration(5000);
animSet.start();

20141231131449937.png

path.moveto lineTo

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在手机上去实现一些动画效果算是件比较炫酷的事情,因此Android系统在一开始的时候就给我们提供了两种实现动画效果...
    Ten_Minutes阅读 3,889评论 3 11
  • 参考于:http://blog.csdn.net/guolin_blog/article/details/4353...
    墨染书阅读 2,980评论 0 2
  • 写的非常好,强烈推荐给大家 转载请注明出处:http://blog.csdn.net/guolin_blog/ar...
    天天大保建阅读 831评论 0 1
  • 今天晚上和宝贝读经典的时候,他答应我的事想不做。用哭和耍赖想不完成。他在那里哭,然后爸爸说。小心他又哭到呕吐。爸爸...
    希望01234阅读 261评论 0 0
  • 一个缘字,一场相遇,当我手执画扇伫立于三生石畔,你那一袭罗衫,手持油纸伞,隔岸相观,彼此眼眸交汇的那一刻,冰封千尺...
    寻找迷失的自我阅读 354评论 1 6