欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 動(dòng)畫之RotateAnimation應(yīng)用詳解

 更新時(shí)間:2012年12月02日 16:29:21   作者:  
本節(jié)講解旋轉(zhuǎn)動(dòng)畫效果RotateAnimation方法的應(yīng)用,有需要的朋友可以參考下
android中提供了4中動(dòng)畫:
AlphaAnimation 透明度動(dòng)畫效果
ScaleAnimation 縮放動(dòng)畫效果
TranslateAnimation 位移動(dòng)畫效果
RotateAnimation 旋轉(zhuǎn)動(dòng)畫效果

本節(jié)講解RotateAnimation 動(dòng)畫,
RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
參數(shù)說明:
float fromDegrees:旋轉(zhuǎn)的開始角度。
float toDegrees:旋轉(zhuǎn)的結(jié)束角度。
int pivotXType:X軸的伸縮模式,可以取值為ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
float pivotXValue:X坐標(biāo)的伸縮值。
int pivotYType:Y軸的伸縮模式,可以取值為ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
float pivotYValue:Y坐標(biāo)的伸縮值。
代碼:
復(fù)制代碼 代碼如下:

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);
/** 設(shè)置旋轉(zhuǎn)動(dòng)畫 */
final RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,
0.5f,Animation.RELATIVE_TO_SELF,0.5f);
animation.setDuration(3000);//設(shè)置動(dòng)畫持續(xù)時(shí)間
/** 常用方法 */
//animation.setRepeatCount(int repeatCount);//設(shè)置重復(fù)次數(shù)
//animation.setFillAfter(boolean);//動(dòng)畫執(zhí)行完后是否停留在執(zhí)行完的狀態(tài)
//animation.setStartOffset(long startOffset);//執(zhí)行前的等待時(shí)間
start.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
image.setAnimation(animation);
/** 開始動(dòng)畫 */
animation.startNow();
}
});
cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
/** 結(jié)束動(dòng)畫 */
animation.cancel();
}
});
}
}

效果:

相關(guān)文章

最新評(píng)論