Android UI(1)-- Android 动画View Animation(Tween Animation)

目录

1、View Animation(Tween Animation)

1)说明

2)scal----渐变尺寸缩放动画

3)alpha----渐变透明度动画

4)translate---- 位置移动动画

5)rotate      旋转动画


1、View Animation(Tween Animation)

1)说明

·只可用于View

常用API:

public class MainActivity extends Activity {
	private Animation animation;
	
	//...dosomething
	
	/**
         * Loads an {@link Animation} object from a resource
         * @param context Application context used to access resources
         * @param id The resource id of the animation to load
	 */
	animation = AnimationUtils.loadAnimation(this, R.anim.count_down_exit);//R.anim.XXX的设置方式可如下2)3)4)5)
	//开始动画
	textView.startAnimation(animation);
	//Reset the initialization state of this animation.<span></span>
         animation.reset();
     /**
     * @param enterAnim A resource ID of the animation resource to use for
     * the incoming activity.  Use 0 for no animation.
     * @param exitAnim A resource ID of the animation resource to use for
     * the outgoing activity.  Use 0 for no animation.
     */
     overridePendingTransition(R.anim.zoomout, R.anim.zoomin);//渐入渐出
     //添加动画监听
     animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }
        @Override
        public void onAnimationRepeat(Animation animation) {
        }
        @Override
        public void onAnimationEnd(Animation animation) {
            //...dosomething..
        }
    });
  }

2)scal----渐变尺寸缩放动画

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <scale
        android:duration="5000"  //动画持续时间
        android:fillAfter="false" //动画结束后是否保留大小
        android:fromXScale="0.0"  //动画开始的X
        android:fromYScale="0.0"  //动画开始的Y
        android:toXScale="1.0"    //动画结束的X
        android:toYScale="1.0"    //动画结束的Y
        android:pivotX="50%" //动画的中心点X
        android:pivotY="50%" //动画的中心店Y
         >
    </scale>
 
</set>

3)alpha----渐变透明度动画

<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <alpha
        android:duration="1000"    //动画持续时间
        android:fromAlpha="0.0"    //动画开始时透明度
        android:toAlpha="1.0" />   //动画结束时透明度
 
</set>

4)translate---- 位置移动动画

    <?xml version="1.0" encoding="utf-8"?>  
    <set xmlns:android="http://schemas.android.com/apk/res/android" >  
      
        <translate  
            android:duration="5000"  //动画过程时间  
            android:fromXDelta="0"   //动画开始时X坐标  
            android:fromYDelta="0"   //动画开始时Y坐标  
            android:toXDelta="100"   //动画结束时X坐标  
            android:toYDelta="100" > //动画结束时Y坐标  
        </translate>  
      
    </set>  

5)rotate      旋转动画

    <?xml version="1.0" encoding="utf-8"?>  
    <set xmlns:android="http://schemas.android.com/apk/res/android">  
        <rotate   
            android:duration="5000" //动画运行时间  
            android:fromDegrees="0"  //旋转开始的角度  
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"  
            android:pivotX="50%"//中心点  
            android:pivotY="50%"//中心点  
            android:toDegrees="+360"  //旋转结束的角度  
                />  
      
    </set>  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值