安卓动画之Tween动画
来源:互联网 发布:Linux进入根目录的命令 编辑:程序博客网 时间:2024/06/09 23:06
Alpha:
/**
fromAlpha:开始时刻的透明度,取值范围0~1。
toAlpha:结束时刻的透明度,取值范围0~1。
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(3000);
animation.setFillAfter(true);//控件保持最终的位置
iv_share.startAnimation(animation);
Trantlate:
/**
float fromXDelta 动画开始的点离当前View X坐标上的差值
float toXDelta 动画结束的点离当前View X坐标上的差值
float fromYDelta 动画开始的点离当前View Y坐标上的差值
float toYDelta 动画开始的点离当前View Y坐标上的差值
TranslateAnimation animation = new TranslateAnimation(0,100, 0,200);
animation.setDuration(3000);
animation.setFillAfter(true);
iv_share.startAnimation(animation);
ScaleAnimation:
/**
第一个参数fromX为动画起始时 X坐标上的伸缩尺寸 0.0表示收缩到没有
第二个参数toX为动画结束时 X坐标上的伸缩尺寸 1.0表示正常无伸缩
第三个参数fromY为动画起始时Y坐标上的伸缩尺寸 值小于1.0表示收缩
第四个参数toY为动画结束时Y坐标上的伸缩尺寸 值大于1.0表示放大
第五个参数pivotXType为动画在X轴相对于物件位置类型
第六个参数pivotXValue为动画相对于物件的X坐标的开始位置
第七个参数pivotXType为动画在Y轴相对于物件位置类型
第八个参数pivotYValue为动画相对于物件的Y坐标的开始位置
ScaleAnimation animation = new ScaleAnimation(0.0f,1.5f, 0.0f,1.5f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
animation.setDuration(3000);
animation.setFillAfter(true);
iv_share.startAnimation(animation);
Rotate(旋转效果):
/**
第一个参数fromDegrees为动画起始时的旋转角度 此角度是当前为0及360,设置其他值则先跳至该角度的位置再 由from - to的值: 负则正向转,正则反向转
第二个参数toDegrees为动画旋转到的角度
第三个参数pivotXType为动画在X轴相对于物件位置类型
第四个参数pivotXValue为动画相对于物件的X坐标的开始位置 此值是以本身原始位置为原点,即如设为20%p,则向右移动父控件的20%位移,为负数则向左移
第五个参数pivotXType为动画在Y轴相对于物件位置类型
第六个参数pivotYValue为动画相对于物件的Y坐标的开始位置 此值是以本身原始位置为原点,即如设为20%p,则向下移动父控件的20%位移,为负数则向上移
RotateAnimation animation = new RotateAnimation(0f, 300f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setDuration(3000);
animation.setFillAfter(true);
iv_share.startAnimation(animation);
动画集合使用方式:
//设置为false每个子动画都用自己的插值器
AnimationSet animationSet = new AnimationSet(false);
animationSet.addAnimation(animation);
animationSet.setDuration(1000);
animationSet.start();;
代码方式介绍完了,接着介绍一下XML方式:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:interpolator="@android:anim/accelerate_interpolator"
子动画支付共享插值器
android:shareInterpolator="true"
动画结束以后是否停留在原来的位置
android:fillAfter="true"
/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"
/>
<translate
android:fromXDelta="0"
android:toXDelta="500"
android:duration="2000"
/>
<scale
android:fromXScale="0.0"
android:toYScale="1.0"
android:fromYScale="0.0"
android:toXScale="1.0"
<!---缩放的节点-->
android:pivotX="9"
android:pivotY="0"
/>
<rotate
android:fromDegrees="0"
android:toDegrees="180"
android:pivotY="2"
android:pivotX="2"/>
</set>
如何应用xml动画呢?
Animation animation = AnimationUtils.loadAnimation(LayoutActivity.this,R.anim.anim_item);
view.startAnimation(animation);
Tween动画的监听器:
TranslateAnimation translateAnimation = new TranslateAnimation(0,90,0,90);
translateAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
//开始执行动画时
}
@Override
public void onAnimationEnd(Animation animation) {
//停止执行动画时
}
@Override
public void onAnimationRepeat(Animation animation) {
//重复执行动画时
}
});
- 安卓动画之Tween动画
- Tween(补间)动画 之 安卓
- 安卓动画之补间动画(Tween Animations)
- Android动画之Tween动画
- Android之Tween动画
- Animation之tween动画
- 安卓动画系列之二,补间动画(Tween Animation)以及动画结合LayoutAnimation的好处
- Android 动画详解之Tween动画
- android的动画之Tween动画
- Tween 动画之AlphaAniamtion(透明度动画
- Android动画之Tween动画实现
- Android 动画详解之Tween动画
- Android 动画详解之Tween动画
- Android动画之Tween Animation变化动画
- Android 动画分析之Tween动画分析
- Android 动画分析之Tween动画分析
- Android 动画详解之Tween动画
- Android Tween动画之RotateAnimation
- 矩阵循环打印
- Android轻量级JSON操作类
- NASM一些特点
- 寒冬
- 以获取的数据信息中的年月日数据为目录名建立目录
- 安卓动画之Tween动画
- Android aidl Binder框架浅析
- 数列求和 阶乘 双精度问题
- 算法矩阵打印2
- [java] DatagramSocket DatagramPacket
- 新建Android项目报错"No resource found that matches the given name 'Theme.AppCompat.Light'."
- python核心编程-GUI程序之综合实例-简单文件浏览器
- 安卓动画之Frame动画
- 【Android服务】制作无法销毁的Service