国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 動畫之RotateAnimation應用詳解

2020-04-11 12:40:20
字體:
來源:轉載
供稿:網友
android中提供了4中動畫:
AlphaAnimation 透明度動畫效果
ScaleAnimation 縮放動畫效果
TranslateAnimation 位移動畫效果
RotateAnimation 旋轉動畫效果

本節講解RotateAnimation 動畫,
RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
參數說明:
float fromDegrees:旋轉的開始角度。
float toDegrees:旋轉的結束角度。
int pivotXType:X軸的伸縮模式,可以取值為ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
float pivotXValue:X坐標的伸縮值。
int pivotYType:Y軸的伸縮模式,可以取值為ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。
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 RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,
0.5f,Animation.RELATIVE_TO_SELF,0.5f);
animation.setDuration(3000);//設置動畫持續時間
/** 常用方法 */
//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();
}
});
}
}

效果:
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定安县| 会东县| 理塘县| 晴隆县| 栖霞市| 凤冈县| 贵定县| 米林县| 宁乡县| 沐川县| 天气| 甘孜县| 洪雅县| 筠连县| 西畴县| 抚松县| 琼海市| 淄博市| 漳浦县| 遂宁市| 彭阳县| 安泽县| 吉水县| 什邡市| 龙胜| 长子县| 达日县| 安远县| 江孜县| 阳城县| 呼伦贝尔市| 靖江市| 沙坪坝区| 田东县| 宜章县| 南岸区| 岳西县| 灵璧县| 蒙山县| 四川省| 桐庐县|