imageView = (ImageView) findViewById(R.id.imageView); //动画 //位移 ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "translationY", 0f, 400f); //旋转 ObjectAnimator animator1 = ObjectAnimator.ofFloat(imageView, "rotation", 0f, 360f); //缩放 ObjectAnimator animator2 = ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 2f); //透明度起始为0,结束时为1 ObjectAnimator animator3 = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1f); //组合 AnimatorSet animatorSet=new AnimatorSet(); animatorSet.play(animator).with(animator1).with(animator2).with(animator3); 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(MainActivity.this,XqActivity.class); startActivity(intent); finish(); } @Override public void onAnimationCancel(Animator animator) { //动画被取消的时候调用 } @Override public void onAnimationRepeat(Animator animator) { //动画重复执行的时候调用 } }); 布局如下<ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:src="@mipmap/ic_launcher" />
简单的组合动画
最新推荐文章于 2020-02-07 18:54:32 发布