package com.bawie.songzixinapp;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class DonghuaActivity extends AppCompatActivity {
private ImageView imageView;
private int time=7;
private Handler handler=new Handler();
private Runnable runnable=new Runnable() {
@Override
public void run() {
time--;
if(time>0){
handler.postDelayed(runnable,1000);
}else{
Intent intent = new Intent(DonghuaActivity.this, MainActivity.class);
startActivity(intent);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_donghua);
imageView = findViewById(R.id.imgge);
startanimaotr();
handler.post(runnable);
}
private void startanimaotr() {
//根据y轴上下平移
ObjectAnimator pingyi = ObjectAnimator.ofFloat(imageView, "translationY", 0, 300);
//渐变
ObjectAnimator jianbian = ObjectAnimator.ofFloat(imageView, "Alpha", 1, 0);
//旋转
ObjectAnimator xuanzhuan = ObjectAnimator.ofFloat(imageView, "rotationY", 0, 180, -180, 0);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(pingyi).with(xuanzhuan).before(jianbian);
animatorSet.setDuration(5000);
animatorSet.start();
}
}