public class WelcomActivity extends AppCompatActivity {
private ImageView imageView;
/* Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
Intent intent=new Intent(WelcomActivity.this,XiangQingActivity.class);
startActivity(intent);
finish();
}
};*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcom);
imageView = findViewById(R.id.image_view);
ObjectAnimator y = ObjectAnimator.ofFloat(imageView, "Y", 0, 500, 800, 1000);
ObjectAnimator alpha = ObjectAnimator.ofFloat(imageView, "alpha", 0.5f, 1);
ObjectAnimator rotationX = ObjectAnimator.ofFloat(imageView, "rotation", 0,90,180,270, 360);
ObjectAnimator rotationY = ObjectAnimator.ofFloat(imageView, "rotation", 0,90,180,270, 360);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageView, "scaleX", 0.5f, 2);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageView, "scaleY", 0.5f, 2);
//组合
AnimatorSet animatorSet = new AnimatorSet();
//放到一起
// animatorSet.play(y).with(alpha).with(scaleX).with(scaleY).with(rotationX);
animatorSet.play(y).with(alpha).with(rotationX).with(rotationY).with(scaleX).with(scaleY);
animatorSet.setDuration(3000);
animatorSet.start();
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
//动画结束跳转页面
Intent intent=new Intent(WelcomActivity.this,XiangQingActivity.class);
startActivity(intent);
finish();
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
}
}
属性动画
最新推荐文章于 2024-01-09 01:05:38 发布