2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Androidのアニメーション(画像複数)

Last updated at Posted at 2018-10-10

アニメーション効果

多数画像のアニメーション効果.gif

1、アニメーションの画像を用意して、drawableに追加
自分は手書きの123、、、9までの数字を用意しました。

2、アニメーションのanimation-listをdrawableに追加(R.drawable.animation)
image.png

3、ImageViewとanimationDrawableの初期化

    //ImageView 初期化
    animationImage = (ImageView)findViewById(R.id.image);
    //AnimationDrawable 初期化
    animationDrawable = (AnimationDrawable)getResources().getDrawable(R.drawable.animation,null);
    //animationImage 背景
    animationImage.setBackground(animationDrawable);

4、開始ボタンと終了ボタンの挙動

public void startAnimation(View view) {
    animationDrawable.start();
}

public void stopAnimation(View view) {
    if(animationDrawable.isRunning()){
        animationDrawable.stop();
    }
}

サンプルコード

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?