普通动画和属性动画

来源:互联网 发布:python 量化 开发环境 编辑:程序博客网 时间:2024/05/21 09:47
mport android.animation.ObjectAnimator;import android.view.View;import android.view.animation.RotateAnimation;/** * Created by Administrator on 2017/11/14. */class Tools {    public static void showView(View view) {//        RotateAnimation r=new RotateAnimation(180,360, view.getWidth()/2,view.getHeight());//        r.setDuration(500);//        r.setFillAfter(true);//        view.startAnimation(r);        ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(view,"rotation",180,360);        objectAnimator.setDuration(500);        objectAnimator.start();        view.setPivotX(view.getWidth() / 2);        view.setPivotY(view.getHeight());    }    public static void showView(View view,int StartOffset) {//        RotateAnimation r=new RotateAnimation(180,360, view.getWidth()/2,view.getHeight());//        r.setDuration(500);//        r.setFillAfter(true);//        r.setStartOffset(StartOffset);//        view.startAnimation(r);        ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(view,"rotation",180,360);        objectAnimator.setDuration(500);        objectAnimator.start();        objectAnimator.setStartDelay(StartOffset);    }    public static void hideView(View view) {//        RotateAnimation r=new RotateAnimation(0,180, view.getWidth()/2,view.getHeight());//        r.setDuration(500);//        r.setFillAfter(true);//        view.startAnimation(r);        ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(view,"rotation",0,180);        objectAnimator.setDuration(500);        objectAnimator.start();        view.setPivotX(view.getWidth() / 2);        view.setPivotY(view.getHeight());    }    public static void hideView(View view,int StartOffset) {//        RotateAnimation r=new RotateAnimation(0,180, view.getWidth()/2,view.getHeight());//        r.setDuration(500);//        r.setStartOffset(StartOffset);//        r.setFillAfter(true);//        view.startAnimation(r);        ObjectAnimator objectAnimator=ObjectAnimator.ofFloat(view,"rotation",0,180);        objectAnimator.setDuration(500);        objectAnimator.start();        objectAnimator.setStartDelay(StartOffset);        view.setPivotX(view.getWidth() / 2);        view.setPivotY(view.getHeight());    }}
原创粉丝点击