public class MainActivity extends AppCompatActivity {
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img = findViewById(R.id.img);
//组合动画
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(img,"y",0,100,200,300,400,500);
//缩放
ObjectAnimator scaleX = ObjectAnimator.ofFloat(img, "scaleX", 2, 1);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(img, "scaleY", 2, 1);
//渐变
ObjectAnimator alpha = ObjectAnimator.ofFloat(img, "alpha", 0.3f, 1);
//旋转
ObjectAnimator animator = ObjectAnimator.ofFloat(img, "rotationY", 0, 360);
animatorSet.play(scaleX).with(scaleY).with(alpha).with(animator).with(objectAnimator);
animatorSet.setDuration(3000);
animatorSet.start();
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
super.onAnimationCancel(animation);
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
Intent intent=new Intent(MainActivity.this,XiangQActivity.class);
startActivity(intent);
finish();
}
@Override
public void onAnimationRepeat(Animator animation) {
super.onAnimationRepeat(animation);
}
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
}
@Override
public void onAnimationPause(Animator animation) {
super.onAnimationPause(animation);
}
@Override
public void onAnimationResume(Animator animation) {
super.onAnimationResume(animation);
}
});
}
}
动画
最新推荐文章于 2023-02-20 17:22:57 发布