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() } })
alpha,rotation,rotationX,rotationY,translationX,translationY,scaleX,scaleY