Android 动画之ScaleAnimation应用详解
===============eoeAndroid社区推荐:=======================
仿QQ--tab切换动画实例(有图有真相哦)
链接地址:http://www.eoeandroid.com/thread-173365-1-1.html
ViewPager多页面滑动切换以及动画效果
链接地址:http://www.eoeandroid.com/thread-157771-1-1.html
自己仿照Path照片分享软件的Button动画效果——欢迎指教
链接地址:http://www.eoeandroid.com/thread-148107-1-1.html
Android动画
链接地址:http://www.eoeandroid.com/thread-60174-1-1.html
Android动画之ScaleAnimation应用详解
android中提供了4中动画:
AlphaAnimation透明度动画效果
ScaleAnimation缩放动画效果
TranslateAnimation位移动画效果
RotateAnimation旋转动画效果
本节讲解ScaleAnimation动画,
ScaleAnimation(floatfromX,floattoX,floatfromY,floattoY,intpivotXType,floatpivotXValue,intpivotYType,floatpivotYValue)
参数说明:
float fromX 动画起始时 X坐标上的伸缩尺寸 float toX 动画结束时 X坐标上的伸缩尺寸 float fromY 动画起始时Y坐标上的伸缩尺寸 float toY 动画结束时Y坐标上的伸缩尺寸 int pivotXType 动画在X轴相对于物件位置类型 float pivotXValue 动画相对于物件的X坐标的开始位置 int pivotYType 动画在Y轴相对于物件位置类型 float pivotYValue 动画相对于物件的Y坐标的开始位置
代码:
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 ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, 
	Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
	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(); 
	} 
	}); 
	} 
	} 相关推荐
  云端漂移    2020-07-17  
   冰蝶    2020-04-20  
   wangdaren    2020-01-14  
   山兔与孟婆    2019-12-15  
   山兔与孟婆    2019-12-14  
   Ladyseven    2020-10-22  
   mapaler    2020-07-17  
   淡风wisdon大大    2020-06-27  
   lanzhusiyu    2020-06-21  
   AlisaClass    2020-06-05  
   jiedinghui    2020-06-04  
   usepython    2020-05-31  
   flycony    2020-05-30  
   88284453    2020-05-09  
   hqulyc    2020-05-05  
   yaodilu    2020-04-30  
   vavid    2020-04-20  
   AlisaClass    2020-04-11