#アニメーション効果
#1、画像設定
imageView.setImageResource(R.mipmap.tellphone);
objectAnimator = AnimationUtil2.getTellphoneAnimation(imageView);
#2、アニメション設定
public static ObjectAnimator getTellphoneAnimation(ImageView imageView) {
Keyframe frame0 = Keyframe.ofFloat(0f, 0);
Keyframe frame1 = Keyframe.ofFloat(0.1f, -20f);
Keyframe frame2 = Keyframe.ofFloat(0.2f, 20f);
Keyframe frame3 = Keyframe.ofFloat(0.3f, -20f);
Keyframe frame4 = Keyframe.ofFloat(0.4f, 20f);
Keyframe frame5 = Keyframe.ofFloat(0.5f, -20f);
Keyframe frame6 = Keyframe.ofFloat(0.6f, 20f);
Keyframe frame7 = Keyframe.ofFloat(0.7f, -20f);
Keyframe frame8 = Keyframe.ofFloat(0.8f, 20f);
Keyframe frame9 = Keyframe.ofFloat(0.9f, -20f);
Keyframe frame10 = Keyframe.ofFloat(1, 0);
PropertyValuesHolder frameHolder = PropertyValuesHolder.ofKeyframe
("rotation",frame0,frame1,frame2,frame3,frame4,frame5,frame6,frame7,frame8,frame9,frame10);
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView,frameHolder);
objectAnimator.setDuration(1000);
objectAnimator.setRepeatCount(2);
objectAnimator.setRepeatMode(ValueAnimator.RESTART);
return objectAnimator;
}
#3、アニメション開始
objectAnimator.start();
いいねも忘れずに