属性动画

来源:互联网 发布:java并发框架有哪些 编辑:程序博客网 时间:2024/06/16 20:08
package kaoshi.dh;import android.animation.AnimatorSet;import android.animation.ObjectAnimator;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.support.v7.app.AppCompatActivity;import android.widget.ImageView;public class MainActivity extends AppCompatActivity {    ImageView imageView;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        imageView= (ImageView) findViewById(R.id.image);        ObjectAnimator animatorA = ObjectAnimator.ofFloat(imageView,"TranslationY",0,450);        ObjectAnimator animatorB = ObjectAnimator.ofFloat(imageView, "scaleY", 2f, 1f);        ObjectAnimator animatorB1 = ObjectAnimator.ofFloat(imageView, "scaleX", 2f, 1f);        ObjectAnimator animatorC = ObjectAnimator.ofFloat(imageView, "rotation", 0, 360);        ObjectAnimator animatorD = ObjectAnimator.ofFloat(imageView, "alpha",0f,1f);        AnimatorSet animatorSet2 = new AnimatorSet();        animatorSet2.playTogether(animatorA,animatorB,animatorC,animatorD,animatorB1);        animatorSet2.setDuration(3*1000);        animatorSet2.start();        new Handler().postDelayed(new Runnable() {            @Override            public void run() {                Intent intent=new Intent(MainActivity.this,Main2Activity.class);                startActivity(intent);                finish();            }        }, 3000);    }}
原创粉丝点击