Android动画

【浅谈Android动画】

总共四种:Tween Animation变换动画、Frame Animation帧动画

          Layout Animation布局动画、Property Animation 属性动画

1、其中-Tween Animation 变换动画包括Alpha渐变透明度动画、Scale渐变尺寸缩放动画

                                 Translate位置移动动画、Rotate旋转动画

                    共同属性包括Duration动画持续时间(单位毫秒)

                                fillAfter设置为true,动画转化在动画结束之后被应用

                                fillBefore设置为true,动画转化在动画开始前被应用

                                interpolator动画插入器(加速、减速插入器)

                                repeatCount动画重复次数

                                repeatMode顺序重复/倒序重复

                                startOffset动画之间的时间间隔

Animation实现方法:一种是通过新建配置文件 /res/anim,再设置alphascaletranslaterotate

                      Animation scale= AnimationUtils.loadAnimation

                                              (TweenActivity.this,R.main.scale_anim);

                      img .startAnimation(scale);

                  另一种是通过Java代码实现AlphaAnimationScaleAnimation

                                           TranslateAnimationRotateAnimation

                      Animation alpha = new AlphaAnimation0.1f1.0f);

                      Alpha.setDuration(5000)

                      img.startAnimation(alpha);

 

2Layout Animation布局动画:可为View Groups添加动画

 

3Frame Animation帧动画:类似小人书中画面的连续转动形成的动画效果

 

4Property Animation 属性动画:属性动画相对于传统的动画优势在于更便于交互,传统动画在设定之后只是在对应的固定位置产生效果,而通过属性动画实现的效果将可依附于对象!

                 实现方法:ObjectAnimator(继承和实现的ValueAnimator-计算动画)

                 设置动画监听事件:AnimatorListenerAdapter()中继承和实现相关方法

                其中注意所涉及的控件实例——借助属性动画,实现动态菜单收敛与拓开效果

                         属性动画中常用的属性有:.translationX/translationY

                                                          .rotationrotationX/rotationY

                                                         .scaleX/scareY

                                                         .X/Y

                                                        .alpha

                       常用的方法和类:.ValueAnimator

                                            .ObjectAnimator

                                           .AnimatorUpdateListener

                                           .AnimatorListenerAdapter

                                           .PropertyValuesHolder

                                           .AnimatorSet 

                                          .TypeEvaluators

                                          .Interpolator

 

posted @ 2015-08-10 15:07  CodingForFuture  阅读(119)  评论(0)    收藏  举报