一、xml
<ImageView
android:id="@+id/imag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/ic_launcher_background"
/>
二、Activity
public class MainActivity extends AppCompatActivity {
private ImageView imagbabi;
private LinearLayout root;
private int width;
private int height;
private AnimatorSet animatorSet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imagbabi = findViewById(R.id.imag);
root = findViewById(R.id.ly_root);
ObjectAnimator translationY = ObjectAnimator.ofFloat(imagbabi, "translationY", imagbabi.getTranslationY(), 800);
ObjectAnimator rotation = ObjectAnimator.ofFloat(imagbabi, "rotation", 0, 360);
ObjectAnimator alpha = ObjectAnimator.ofFloat(imagbabi, "alpha", 1, 2, 3);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(imagbabi, "scaleX", 0, 1);
animatorSet = new AnimatorSet();
animatorSet.play(translationY).with(rotation).with(alpha).with(scaleX);
animatorSet.setDuration(5000);
animatorSet.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(MainActivity.this,ShowActivity.class));
finish();
}
},5000);
}
}