- 首页 > it技术 > >
public class SplashActivity extends AppCompatActivity {@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
//查找控件
ImageView imageView = findViewById(R.id.action_image);
//设置图片
Glide.with(this).load(R.drawable.splash)
.apply(bitmapTransform(new CenterCrop()))
.into(imageView);
//设置位移
ObjectAnimator trans = ObjectAnimator.ofFloat(imageView, "translationY",0f, 500f);
//设置缩放x
ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageView, "scaleX", 2f, 1f);
//设置缩放y
ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageView, "scaleY", 2f, 1f);
//设置透明到不透明
ObjectAnimator alpha = ObjectAnimator.ofFloat(imageView, "alpha", 0.0f, 1f).setDuration(1000);
// 旋转为旋转一圈
ObjectAnimator rotation = ObjectAnimator.ofFloat(imageView, "rotation", 0f, 360f).setDuration(1000);
//设置组合动画
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(trans);
animatorSet.play(scaleX);
animatorSet.play(scaleY);
animatorSet.play(alpha);
animatorSet.play(rotation);
//设置时间,启动
animatorSet.setDuration(3000).start();
//设置监听
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {}//结束的方法
@Override
public void onAnimationEnd(Animator animation) {
Intent intent = new Intent(SplashActivity.this,GoodContActivity.class);
startActivity(intent);
finish();
}@Override
public void onAnimationCancel(Animator animation) {}@Override
public void onAnimationRepeat(Animator animation) {}
});
}
}
推荐阅读