//创建动画 AnimatorSet set = AnimatorUtils.setAnimatorSet(SplashActivity.this, img1); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); startActivity(new Intent(SplashActivity.this, MainActivity.class)); //加跳转动画 overridePendingTransition(R.anim.enter, R.anim.out); //结束掉本页面 finish(); }});
//还要一个类
public static AnimatorSet setAnimatorSet(Context context, View view) { //获取屏幕一般 DisplayMetrics metrics = context.getResources().getDisplayMetrics(); int heightPixels = metrics.heightPixels;//平移 ValueAnimator tranlate = ObjectAnimator.ofFloat(view, "translationY", 0, heightPixels / 2 - view.getHeight());//伸缩XValueAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 2.0f, 1.0f);//伸缩YValueAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 2.0f, 1.0f); //透明ValueAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0, 1.0f); //旋转ValueAnimator rotation = ObjectAnimator.ofFloat(view, "rotation", 0, 360); //创建动画集合 AnimatorSet set = new AnimatorSet(); set.playTogether(tranlate, scaleX, scaleY, alpha, rotation); set.setDuration(3000); set.start(); return set; }
动画集合
最新推荐文章于 2022-04-28 16:42:26 发布