• android——ObjectAnimator动画(一)


    直接贴上集中用法

    package com.example.test;
    
    import com.example.test.views.CircleView;
    
    import android.animation.Animator;
    import android.animation.AnimatorSet;
    import android.animation.Keyframe;
    import android.animation.ObjectAnimator;
    import android.animation.PropertyValuesHolder;
    import android.annotation.SuppressLint;
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    
    public class CircleViewActivity extends Activity {
        
        private com.example.test.views.CircleView cv ;
        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_circleview);
            move();
        }
        
        public void move(){
            cv = (CircleView)findViewById(R.id.cv);
            
    //        ObjectAnimator.ofFloat(cv, "translationX", 0F,200F).setDuration(1000).start();
    //        ObjectAnimator.ofFloat(cv, "translationY", 0F,200F).setDuration(1000).start();
    //        ObjectAnimator.ofFloat(cv, "rotation", 0F,360F).setDuration(1000).start();
    //        PropertyValuesHolder holder = PropertyValuesHolder.ofFloat("rotation", 0F,360F);
    //        PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat("translationY", 0F,200F);
    //        PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat("translationX", 0F,200F);
    //        ObjectAnimator.ofPropertyValuesHolder(cv, holder,holder1,holder2).setDuration(1000).start();
            
    //        ObjectAnimator a1 =ObjectAnimator.ofFloat(cv, "translationX", 0F,200F);
    //        ObjectAnimator a2 =ObjectAnimator.ofFloat(cv, "translationY", 0F,200F);
    //        ObjectAnimator a3 =ObjectAnimator.ofFloat(cv, "rotation", 0F,360F);
    //        AnimatorSet set = new AnimatorSet();
    ////        set.playSequentially(a1,a2,a3);
    ////        set.playTogether(a1,a2,a3);  //展示方式不能一起使用。
    //        set.play(a2).before(a1);  //顺序控制
    //        set.play(a2).before(a3);
    //        set.setDuration(1000);
    //        set.start();
            Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
            Keyframe kf1 = Keyframe.ofFloat(.5f, 360f);
            Keyframe kf2 = Keyframe.ofFloat(.2f, 720f);
            PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2);
            ObjectAnimator rotationAnim = ObjectAnimator.ofPropertyValuesHolder(cv, pvhRotation);
            rotationAnim.setDuration(5000);
            rotationAnim.start();
    //        ObjectAnimator.ofArgb(cv, ACCESSIBILITY_SERVICE, 244).setDuration(1000).start();
            
        }
    
    }
  • 相关阅读:
    穷人思维与富人思维
    纯真IP库读取文件
    memcached 分布式 一致性hash算法demo
    纯CSS画的基本图形(矩形、圆形、三角形、多边形、爱心、八卦等)
    IPhone在横屏字体变大解决办法-webkit-text-size-adjust
    js设计模式---阅读笔记002--接口
    js设计模式---阅读笔记001--富有表现力的js
    关于js继承
    js正则表达式中test,exec,match方法的区别说明
    js获取自定义的属性值
  • 原文地址:https://www.cnblogs.com/shoneworn/p/5029337.html
Copyright © 2020-2023  润新知