android 代码中设置动画
2014-03-28 17:51
387 查看
参考来源:http://blog.csdn.net/rhljiayou/article/details/7194807
动画的分类:
Represents a group of Animations that should be played together. The transformation of each individual animation are composed together into a single transform. If AnimationSet sets any properties that its children also set (for example, duration or fillBefore),
the values of AnimationSet override the child values.
意思是:代表一群动画应该一同玩耍。转变是由每个个体的动画在一起,成为一个单一的变换。如果AnimationSet设置任何属性,其子女也设置(例如,持续时间或fillBefore)的值AnimationSet推翻这孩子的价值观。
动画的分类:
private void initAnimation() { /** * 透明度控制动画效果 alpha */ animation_alpha=new AlphaAnimation(0.1f,1.0f); //第一个参数fromAlpha为 动画开始时候透明度 //第二个参数toAlpha为 动画结束时候透明度 animation_alpha.setRepeatCount(-1);//设置循环 animation_alpha.setDuration(5000);//设置时间持续时间为 5000毫秒 /** * 旋转效果rotate */ animation_rotate = new RotateAnimation(0, -720, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); //第一个参数fromDegrees为动画起始时的旋转角度 //第二个参数toDegrees为动画旋转到的角度 //第三个参数pivotXType为动画在X轴相对于物件位置类型 //第四个参数pivotXValue为动画相对于物件的X坐标的开始位置 //第五个参数pivotXType为动画在Y轴相对于物件位置类型 //第六个参数pivotYValue为动画相对于物件的Y坐标的开始位置 animation_rotate.setRepeatCount(-1); animation_rotate.setDuration(5000);//设置时间持续时间为 5000毫秒 /** * 尺寸伸缩动画效果 scale */ animation_scale=new ScaleAnimation(0.1f,3.0f,0.1f,3.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); //第一个参数fromX为动画起始时 X坐标上的伸缩尺寸 //第二个参数toX为动画结束时 X坐标上的伸缩尺寸 //第三个参数fromY为动画起始时Y坐标上的伸缩尺寸 //第四个参数toY为动画结束时Y坐标上的伸缩尺寸 /*说明: 以上四种属性值 0.0表示收缩到没有 1.0表示正常无伸缩 值小于1.0表示收缩 值大于1.0表示放大 */ //第五个参数pivotXType为动画在X轴相对于物件位置类型 //第六个参数pivotXValue为动画相对于物件的X坐标的开始位置 //第七个参数pivotXType为动画在Y轴相对于物件位置类型 //第八个参数pivotYValue为动画相对于物件的Y坐标的开始位置 animation_scale.setRepeatCount(-1); animation_scale.setDuration(5000);//设置时间持续时间为 5000毫秒 /** * 移动动画效果translate */ animation_translate=new TranslateAnimation(-20f,300f,-20f,300f); //第一个参数fromXDelta为动画起始时 X坐标上的移动位置 //第二个参数toXDelta为动画结束时 X坐标上的移动位置 //第三个参数fromYDelta为动画起始时Y坐标上的移动位置 //第三个参数toYDelta为动画结束时Y坐标上的移动位置 animation_translate.setRepeatCount(-1);//设置动画执行多少次,如果是-1的话就是一直重复 animation_translate.setDuration(5000);//设置时间持续时间为 5000毫秒 animationSet=new AnimationSet(true); animationSet.addAnimation(animation_alpha);//透明度 animationSet.addAnimation(animation_rotate);//旋转 animationSet.addAnimation(animation_scale);//尺寸伸缩 animationSet.addAnimation(animation_translate);//移动 image.startAnimation(animationSet);//开始播放 }
AnimationSet这个类是:
Represents a group of Animations that should be played together. The transformation of each individual animation are composed together into a single transform. If AnimationSet sets any properties that its children also set (for example, duration or fillBefore),the values of AnimationSet override the child values.
意思是:代表一群动画应该一同玩耍。转变是由每个个体的动画在一起,成为一个单一的变换。如果AnimationSet设置任何属性,其子女也设置(例如,持续时间或fillBefore)的值AnimationSet推翻这孩子的价值观。
相关文章推荐
- Android ViewPager简单几行代码设置滑动动画
- android 后台代码设置动画
- Android 墙纸设置代码 详细说明
- Android在代码中设置控件的drawableLeft,drawableRight,drawableTop,drawableBottom。
- android中xml设置Animation动画效果详解
- android基本动画,代码构建动画
- Android自定义控件:动画类(十)----AnimatorSet联合动画的代码实现
- Android加载Gif动画实现代码
- Android笔记 四种方案解决ScrollView嵌套ListView问题之动态设置ListView高度代码整理
- android代码设置EditText只输入数字、字母
- android 在代码中使用 #ffffff 模式 设置背景色
- 2014-11-3Android学习------关于R.styleable的问题(一)实例代码--------GIF动画实现
- Android中给按钮同时设置背景和圆角示例代码
- Android中级篇之Fresco-更灵活的设置加载特效[Java代码实现XML效果]
- [Android_Develop]使用RGB值在代码中实时设置图片背景颜色
- Android 在java代码中设置EditText只接受数字输入
- Android属性动画应用超简单代码打造酷炫扇形(卫星),圆形菜单
- Android 在代码中设置ProgressBar的style
- Android 在Java代码中设置style属性--使用代码创建ProgressBar对象
- 从零开始--系统深入学习android(实践-让我们开始写代码-Android框架学习-5.设置(Settings))