• 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演示看到的效果是图片一边旋转一边消失

    源代码下载

    点击打开链接

  • 相关阅读:
    Jquery:强大的选择器<一>
    要经营我的园子了!!!
    Json在Struts中的转换与传递
    MyEclipse快捷键大全
    Pyqt在QListWidget中添加右键菜单
    swift中Double转String
    Spring MVC 关于分页的简单实现
    Spring MVC 通过@Value注解读取.properties配置内容
    SQL 查询语句(备份)
    Idea使用说明
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3297111.html
Copyright © 2020-2023  润新知