JakeWharton / NineOldAndroids

[DEPRECATED] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!
http://nineoldandroids.com
Apache License 2.0
4.49k stars 1.53k forks source link

ObjectAnimator does not proxy View properties when created from PropertyValuesHolder #48

Open dlew opened 11 years ago

dlew commented 11 years ago

I noticed this when I switched my code from using multiple ObjectAnimators to using a single ObjectAnimator + multiple PropertyValuesHolders.

This code will work:

ObjectAnimator.ofFloat(myView, "alpha", 0f, 1f).start();

This code will not work:

PropertyValuesHolder pvh = PropertyValuesHolder.ofFloat("alpha", 0f, 1f);
ObjectAnimator.ofPropertyValuesHolder(myView, pvh).start();

The culprit is pretty obvious, you see this in LogCat:

E/PropertyValuesHolder(4615): Couldn't find setter/getter for property alpha with value type float

It seems to me that PVH should be able to proxy a View's properties just as well as a vanilla ObjectAnimator. Obviously it's an extra layer of indirection but if ObjectAnimator can do it, PropertyValuesHolder should be able to do so as well.

scottdweber commented 11 years ago

It seems like this ought to be built into the library, but there is a workaround:

PropertyValuesHolder pvh = PropertyValuesHolder.ofFloat("alpha", 0f, 1f);
ObjectAnimator.ofPropertyValuesHolder(AnimatorProxy.NEEDS_PROXY ?
        AnimatorProxy.wrap(myView) : myView, pvh).start();