Android视频教程AlphaAnimation详解
                            
                                0
                                
                            
                        
                        
                            常见的android视频教程中经常会提到如下4种动画效果: 
1、AlphaAnimation 透明度动画效果
2、ScaleAnimation 缩放动画效果
3、TranslateAnimation 位移动画效果
4、RotateAnimation 旋转动画效果
这4种效果是当今android开发的主流手段,一般大型的android开发项目中都会用到。对于android初学者来说,必须要牢牢掌握这4种效果。今天主要讲解AlphaAnimation透明度动画效果的实现方法。常用于窗口动画效果、LOGO淡入淡出的实现。
android开发 AlphaAnimation代码示例:
	
		
	
                            
                            
                        1、AlphaAnimation 透明度动画效果
2、ScaleAnimation 缩放动画效果
3、TranslateAnimation 位移动画效果
4、RotateAnimation 旋转动画效果
这4种效果是当今android开发的主流手段,一般大型的android开发项目中都会用到。对于android初学者来说,必须要牢牢掌握这4种效果。今天主要讲解AlphaAnimation透明度动画效果的实现方法。常用于窗口动画效果、LOGO淡入淡出的实现。
android开发 AlphaAnimation代码示例:
- 
				public class MainActivity extends Activity { 
 
- 
				ImageView image; 
 
- 
				Button start; 
 
- 
				Button cancel; 
 
- 
				@Override 
 
- 
				public void onCreate(Bundle savedInstanceState) { 
 
- 
				super.onCreate(savedInstanceState); 
 
- 
				setContentView(R.layout.activity_main); 
 
- 
				image = (ImageView) findViewById(R.id.main_img); 
 
- 
				start = (Button) findViewById(R.id.main_start); 
 
- 
				cancel = (Button) findViewById(R.id.main_cancel); 
 
- 
				/** 设置透明度渐变动画 */ 
 
- 
				final AlphaAnimation animation = new AlphaAnimation(1, 0); 
 
- 
				animation.setDuration(2000);//设置动画持续时间 
 
- 
				/** 常用方法 */ 
 
- 
				//animation.setRepeatCount(int repeatCount);//设置重复次数 
 
- 
				//animation.setFillAfter(boolean);//动画执行完后是否停留在执行完的状态 
 
- 
				//animation.setStartOffset(long startOffset);//执行前的等待时间 
 
- 
				start.setOnClickListener(new OnClickListener() { 
 
- 
				public void onClick(View arg0) { 
 
- 
				image.setAnimation(animation); 
 
- 
				/** 开始动画 */ 
 
- 
				animation.startNow(); 
 
- 
				} 
 
- 
				}); 
 
- 
				cancel.setOnClickListener(new OnClickListener() { 
 
- 
				public void onClick(View v) { 
 
- 
				/** 结束动画 */ 
 
- 
				animation.cancel(); 
 
- 
				} 
 
- 
				}); 
 
- 
				} 
 
- }
