Android属性动画——平移,旋转,渐变,缩放及属性动画的生命周期

【Android属性动画——平移,旋转,渐变,缩放及属性动画的生命周期】操作如下:

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); l = (LinearLayout)findViewById(R.id.l); l.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {//平移 ObjectAnimator translationX = new ObjectAnimator().ofFloat(l,"translationX",0,600f); ObjectAnimator translationY = new ObjectAnimator().ofFloat(l,"translationY",0,0); AnimatorSet animatorSet = new AnimatorSet(); //组合动画 animatorSet.playTogether(translationX,translationY); //设置动画 animatorSet.setDuration(10000); //设置动画时间 animatorSet.start(); //启//// 旋转 //ObjectAnimator ra = ObjectAnimator.ofFloat(l,"rotation", 0f, 360f); //ra.setDuration(3000); //ra.start(); //// 缩放 //AnimatorSet animatorSetsuofang = new AnimatorSet(); //组合动画 //ObjectAnimator scaleX = ObjectAnimator.ofFloat(l, "scaleX", 0, 1f); //ObjectAnimator scaleY = ObjectAnimator.ofFloat(l, "scaleY", 0, 1f); //animatorSetsuofang.setDuration(5000); //animatorSetsuofang.setInterpolator(new DecelerateInterpolator()); //animatorSetsuofang.play(scaleX).with(scaleY); //两个动画同时开始//// 渐变 //ObjectAnimator anim = ObjectAnimator.ofFloat(l, "alpha", 1f, 0.1f, 1f, 0.5f, 1f); //anim.setDuration(10000); // 动画持续时间 //anim.start(); // 动画的监听事件 animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { Log.d("动画开始",""); }@Override public void onAnimationEnd(Animator animation) { Log.d("动画结束,跳转",""); }@Override public void onAnimationCancel(Animator animation) { Log.d("动画取消",""); }@Override public void onAnimationRepeat(Animator animation) { Log.d("动画重复",""); } }); } }); }

    推荐阅读