安卓属性动画

来源:互联网 发布:矩阵向量化公式 编辑:程序博客网 时间:2024/05/18 02:27
public void btn_alpha(View v){//渐变    ObjectAnimator animator=ObjectAnimator.ofFloat(iv,"alpha",0f,1f);    animator.setDuration(1000);    animator.setRepeatCount(1);    animator.setRepeatMode(ValueAnimator.RESTART);    animator.start();}public void btn_robot(View v){//旋转    ObjectAnimator animator=ObjectAnimator.ofFloat(iv,"rotation",0f,360f);    animator.setDuration(1000);    animator.setRepeatCount(1);    animator.setRepeatMode(ValueAnimator.RESTART);    animator.start();}public void btn_tran(View v){//偏移    ObjectAnimator animator=ObjectAnimator.ofFloat(iv,"translationX",0,360);    animator.setDuration(1000);    animator.setRepeatCount(1);    animator.setRepeatMode(ValueAnimator.REVERSE);    animator.start();}public void btn_suo(View v){//缩放    ObjectAnimator animator=ObjectAnimator.ofFloat(iv,"scaleX",1f,0.5f);    animator.setDuration(1000);    animator.setRepeatCount(1);    animator.setRepeatMode(ValueAnimator.RESTART);    animator.start();}public void btn_set(View v){//集合    ObjectAnimator animator1=ObjectAnimator.ofFloat(iv,"scaleX",1f,0.5f);    ObjectAnimator animator2=ObjectAnimator.ofFloat(iv,"translationX",0,360);    ObjectAnimator animator=ObjectAnimator.ofFloat(iv,"rotation",0f,360f);    AnimatorSet set=new AnimatorSet();    //在旋转之后 after rotation    set.play(animator1).with(animator2).before(animator);    set.setDuration(2000);    set.start();}
原创粉丝点击