属性动画

来源:互联网 发布:算法 中文版 pdf 编辑:程序博客网 时间:2024/06/08 12:47
public class MainActivity extends AppCompatActivity {    private ImageView img;    private Handler handler = new Handler() {        @Override        public void handleMessage(Message msg) {            super.handleMessage(msg);            if(msg.what == 1){                Intent intent = new Intent(MainActivity.this,ShopActivity.class);                startActivity(intent);                finish();            }        }    };    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        img = findViewById(R.id.img);        ObjectAnimator animator1 = ObjectAnimator.ofFloat(                img,                "translationY",                0, 400        );        ObjectAnimator animator2 = ObjectAnimator.ofFloat(                img,                "alpha",                0, 1        );        ObjectAnimator animator3 = ObjectAnimator.ofFloat(                img,                "scaleY",                1, 2        );        ObjectAnimator animator4 = ObjectAnimator.ofFloat(                img,                "rotationY",                0, 360        );        AnimatorSet animatorSet = new AnimatorSet();        animatorSet.setDuration(3000);        animatorSet.play(animator1)                .with(animator2)                .with(animator3)                .with(animator4);        animatorSet.start();        new Thread(){            @Override            public void run() {                super.run();                Message msg = new Message();                msg.what = 1;                handler.sendMessageDelayed(msg,3000);            }        }.start();}}