• Android常用动画alpha和rotate同时使用


    Android的动画可以是一种动画,也可以多种动画作用于一张图片上,如RotaeAnimation和AlphaAnimation同时放到一个配置文件中

    alpha1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_interpolator" >
    
        <alpha
            android:duration="3000"
            android:fromAlpha="1.0"
            android:toAlpha="0.0"
            android:startOffset="500" />
        
        <rotate
            android:duration="3000"
            android:fromDegrees="0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toDegrees="+360" />
    
    </set>


    package com.example.animation;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.Button;
    import android.widget.ImageView;
    
    import com.example.widgetdemo.R;
    
    public class AnimationXmlDemo2 extends Activity{
    	private Button alpha = null;
    	private ImageView image = null;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.animation_xml2);
    		alpha = (Button) findViewById(R.id.alpha);
    		image = (ImageView) findViewById(R.id.image);
    		alpha.setOnClickListener(new alphaListener());
    	}
    	
    	class alphaListener implements OnClickListener {
    
    		@Override
    		public void onClick(View arg0) {
    			// TODO Auto-generated method stub
    			Animation animation = AnimationUtils.loadAnimation(AnimationXmlDemo2.this, R.anim.alpha1);
    			image.startAnimation(animation);
    		}
    
    	}
    }
    



    点击alpha演示看到的效果是图片一边旋转一边消失

    源代码下载

    点击打开链接

  • 相关阅读:
    printf,sprintf,fprintf的区别与联系
    linux repo init 遇到的问题
    POSTMAN使用说明
    HTTP协议-深入了解
    HTTP协议-详解篇
    HTTP协议-基础篇
    多线程学习
    I/O流
    String类学习&泛型
    集合
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3297111.html
Copyright © 2020-2023  润新知