属性动画

//获取屏幕宽高
      WindowManager wm = (WindowManager) this
                .getSystemService(Context.WINDOW_SERVICE);
        width = wm.getDefaultDisplay().getWidth();
        height = wm.getDefaultDisplay().getHeight();

//属性动画

ImageView imageView=findViewById(R.id.splash_pic);
        //属性动画
        ObjectAnimator translationY = ObjectAnimator.ofFloat(imageView, "translationY", 0, height / 2);
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageView, "scaleX", 2, 1); //横向缩放
        ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageView, "scaleY", 2, 1); //纵向缩放
        ObjectAnimator alpha = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1); // 透明度
        ObjectAnimator rotation = ObjectAnimator.ofFloat(imageView, "rotation", 360); //旋转

        //添加到动画集合
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(translationY,scaleX,scaleY,alpha,rotation);

        //设置
        animatorSet.setDuration(3000);
        animatorSet.start();
        animatorSet.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                //动画结束的时候,跳转页面
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });

猜你喜欢

转载自blog.csdn.net/user_app/article/details/80102490