Android Animation Sample Code

I can look together Android animations.

The ImageView instance ※ iv.

◆ Move
/ / TranslateAnimation (float fromX, float toX, float fromY, float toY)
translate = new TranslateAnimation (0, 30, 0, 30);
/ / Set the change time 3000 ms
translate.setDuration (3000);
/ / Repeat 3 times
translate.setInterpolator (new CycleInterpolator (3));
/ / Start animation
iv.startAnimation (translate);

◆ transparency
/ / AlphaAnimation (float fromAlpha, float toAlpha)
alpha = new AlphaAnimation (1, 0);
/ / Set the change time 5000 ms
alpha.setDuration (5000);
/ / Repeat 3 times
alpha.setInterpolator (new CycleInterpolator (3));
/ / Start animation
iv.startAnimation (alpha);

◆ rotation
/ / RotateAnimation (float from, float to, float pivotX, float pivotY)
rotate = new RotateAnimation (0, 360, 150, 150);
/ / Set the change time 3000 ms
rotate.setDuration (3000);
/ / Repeat 3 times
rotate.setInterpolator (new CycleInterpolator (3));
/ / Start animation
iv.startAnimation (rotate);

◆ Zoom
/ / ScaleAnimation (float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
scale = new ScaleAnimation (1, 2, 1, 2, 150, 150);
/ / Set the change time 3000 ms
scale.setDuration (3000);
/ / Repeat 3 times
scale.setInterpolator (new CycleInterpolator (3));
/ / Start animation
iv.startAnimation (scale);

◆ Complex
/ / Initialize animation sets
mix1 = new AnimationSet (true);
/ / Set rotation
mix1.addAnimation (rotate);
/ / Set scaling
mix1.addAnimation (scale);
/ / Repeat 2 times
mix1.setInterpolator (new CycleInterpolator (2));
/ / Start animation

There are videos and sample code on this site.

Androidアプリ講座オープン
副業大学にAndroidアプリ作成講座がオープン。
アフィリエイトやドロップシッピングも学べるお得な大学。

innc.japan-power.biz
カテゴリー: Android アプリ 関連 情報   パーマリンク