- 2008-01-27 0:19
- android
Androidで準備されているアニメーションを色々試してみます。
アニメーションの対象は以下のImageViewです。
<ImageView id="@+id/img"
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />ImageView img = (ImageView) findViewById(R.id.img);
TranslateAnimation
移動するアニメーション。
//TranslateAnimation(float fromX, float toX, float fromY, float toY) TranslateAnimation translate = new TranslateAnimation(0, 10, 0, 0); //1000msの間で translate.setDuration(1000); //7回繰り返す translate.setInterpolator(new CycleInterpolator(7)); //アニメーションスタート img.startAnimation(translate);
スクリーンキャスト
AlphaAnimation
透明度が変化するアニメーション。
//AlphaAnimation(float fromAlpha, float toAlpha) AlphaAnimation alpha = new AlphaAnimation(1, 0); //1000msの間で alpha.setDuration(1000); //3回繰り返す alpha.setInterpolator(new CycleInterpolator(3)); //アニメーションスタート img.startAnimation(alpha);
スクリーンキャスト
RotateAnimation
ぐるぐる回るアニメーション。
//RotateAnimation(float from, float to, float pivotX, float pivotY) RotateAnimation rotate = new RotateAnimation(0, 360, 30, 90); //1000msで回転する rotate.setDuration(1000); //アニメーションスタート img.startAnimation(rotate);
スクリーンキャスト
ScaleAnimation
スケールを変更するアニメーション。
//ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY) ScaleAnimation scale = new ScaleAnimation(1,2,1,2, 30, 90); //1000msの間で scale.setDuration(1000); //1回繰り返す scale.setInterpolator(new CycleInterpolator(1)); //アニメーションスタート img.startAnimation(scale);
スクリーンキャスト
AnimationSet
アニメーションを組み合わせる。
//AnimationSet(boolean shareInterpolator) AnimationSet set = new AnimationSet(true); //くるくる回転しながら set.addAnimation(rotate); //スケールが変化する set.addAnimation(scale); //繰り返し回数は1 set.setInterpolator(new CycleInterpolator(1)); //アニメーションスタート img.startAnimation(set);
スクリーンキャスト
おわりに
SizeAnimationのエフェクトがよくわかりません…。
関連のありそうなエントリ
- Newer: Androidで地図アプリケーションを作ってみた
- Older: イマドキのAndroidアプリケーション開発方法
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://www.adamrocker.com/blog/181/android_animation.html/trackback/
- Listed below are links to weblogs that reference
- Androidのアニメーションいろいろ from throw Life
