安卓动画学习(四) ---PropertyValuesHolder的介绍

匿名 (未验证) 提交于 2019-12-03 00:19:01
    public static ObjectAnimator ofPropertyValuesHolder(Object target,PropertyValuesHolder... values)   

PropertyValuesHolder

public static PropertyValuesHolder ofFloat(String propertyName, float... values) {         return new FloatPropertyValuesHolder(propertyName, values);     } 
private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap =                 new HashMap<Class, HashMap<String, Long>>();         long mJniSetter;         private FloatProperty mFloatProperty;          Keyframes.FloatKeyframes mFloatKeyframes;         float mFloatAnimatedValue; 
 public static ObjectAnimator ofPropertyValuesHolder(Object target,PropertyValuesHolder... values)   
    PropertyValuesHolder rotationHolder = PropertyValuesHolder.ofFloat("Rotation", 60f, -60f, 40f, -40f, -20f, 20f, 10f, -10f, 0f);       PropertyValuesHolder colorHolder = PropertyValuesHolder.ofInt("BackgroundColor", 0xffffffff, 0xffff00ff, 0xffffff00, 0xffffffff);       ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mTextView, rotationHolder, colorHolder);       animator.setDuration(3000);       animator.setInterpolator(new AccelerateInterpolator());       animator.start();   

Keyframe

    public static Keyframe ofFloat(float fraction, float value)   
    public static PropertyValuesHolder ofKeyframe(String propertyName, Keyframe... values)   
Button button = findViewById(R.id.main_useKeyFrameViewBt);         ImageView imageView = findViewById(R.id.main_useKeyFrameViewIv);         Keyframe keyframe = Keyframe.ofFloat(0,0);         Keyframe keyframe0 = Keyframe.ofFloat(0.3f,-200);         Keyframe keyframe1 = Keyframe.ofFloat(0.5f,200);         Keyframe keyframe2 = Keyframe.ofFloat(1f,100);         PropertyValuesHolder holder = PropertyValuesHolder.ofKeyframe("translationY",keyframe,keyframe0         ,keyframe1,keyframe2);          final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView,holder);         animator.setDuration(3000);         button.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View v) {                 animator.start();             }         }); 
alpharotationrotationXrotationY,translationX,translationY,scaleX,scaleY 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!