详细的补间动画笔记(仅参考,无代码)

来源:互联网 发布:帝国cms 相关文章 编辑:程序博客网 时间:2024/05/21 14:05


补间动画  渐变,旋转,平移,缩放
渐变 Alpha①:
创建渐变的animation对象  参数是透明度
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
设置动画的播放时间
animation.setDuration(3000);
设置动画播放的次数
animation.setRepeatCount(3);
iv.startAnimation(animation);


渐变 Alpha②:
创建文件夹anim然后创建文件
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
//设置透明度开始和结束
android:fromAlpha="1.0"
android:toAlpha="0.0"
//设置时间
android:duration="3000"
//设置次数
android:repeatCount="3"
//动画播放完毕后保持动画播放后的样子
android:fillAfter="true"
//动画播放完下一遍倒着播放
android:repeatMode="reverse"
//创建对象
Animation animation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.alpha);
//开始
iv.startAnimation(animation);






旋转 Rotate①:
//创建对象 参数:开始的角度,结束的角度,根据谁旋转,X轴的点,根据谁旋转,Y轴的点 都是0.5f就是图片的中心
RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
次数
animation.setRepeatCount(2);
时间
animation.setDuration(3000);
开始
iv.startAnimation(animation);


旋转 Rotate②:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
起始结束角度
android:fromDegrees="0"
android:toDegrees="720"
XY轴的点
android:pivotX="50%"
android:pivotY="50%"
//动画播放完下一遍倒着播放
android:repeatMode="reverse"
次数
android:repeatCount="2"
时间
android:duration="500">






平移 Translate①:
创建对象 参数:现对于父控件,X轴起始点,现对于父控件,X轴结束点,现对于父控件,Y轴起始点,现对于父控件,Y轴结束点,
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1, Animation.RELATIVE_TO_PARENT,1, Animation.RELATIVE_TO_PARENT, 0,Animation.RELATIVE_TO_PARENT, 0);
时间
animation.setDuration(3000);
开始
iv.startAnimation(animation);


平移 Translate②:
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="-100%p"
android:fromYDelta="0%p"
android:toXDelta="100%p"
android:toYDelta="0%p"
android:duration="3000" >






缩放 Scale①:
创建对象 参数: X轴起始大小,X轴结束大小,Y轴起始大小,Y轴结束大小,相对于自己,中间,相对于自己,中间
ScaleAnimation animation = new ScaleAnimation(2.0f, 0.5f, 2.0f,0.5f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
时间
animation.setDuration(3000);
开始
iv.startAnimation(animation);


缩放 Scale②:
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:toXScale="3.0"
android:fromYScale="1.0"
android:duration="3000"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%">


-----------------------------------------------------------------------------分割线


给ListView的每一个条目设置动画
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha);
LayoutAnimationController controller = new LayoutAnimationController(animation );
controller.setDelay(0.5f);
给ListView的每一个条目设置播放顺序
controller.setOrder(LayoutAnimationController.ORDER_REVERSE);
lv.setLayoutAnimation(controller);


------------------------------------------------------------------------------分割线


给Activity跳转关闭等设置动画
overridePendingTransition(R.anim.trans1,R.anim.trans2);
原创粉丝点击