LoginSignup
3
2

More than 5 years have passed since last update.

Androidのアニメーション(ハート)

Posted at

アニメーション効果

ハートアニメション.gif

1、リソースファイル設定ObjectAnimator取得

            imageView.setImageResource(R.mipmap.heart);
            objectAnimator = AnimationUtil2.getHertAnimation(imageView);

2、ObjectAnimatorの作成

public static ObjectAnimator getHertAnimation(ImageView img_hert) {
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha" , 1.0f , 0.5f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX" , 1.2f , 0.8f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY" , 1.2f , 0.8f);

    ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(img_hert,alpha,scaleX,scaleY);
    objectAnimator.setDuration(2000);
    objectAnimator.setRepeatCount(Animation.INFINITE);
    objectAnimator.setRepeatMode(ValueAnimator.RESTART);
    return objectAnimator;
}

3、アニメション開始

            objectAnimator.start();

ソースコード

いいねも忘れずに:point_up:

3
2
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
3
2