PropertyValuesHolder: Couldn't find setter/get

2019-06-08 13:52发布

问题:

I am facing the following issue when I am using PropertyValuesHolder.ofFloat(....)

PropertyValuesHolder: Couldn't find setter/getter for property < Property-name > with value type float

Other wise it is working good if I replace .ofFloat(...) to ofInt(....)

By using ofInt(....), the animation is not animating smoothly.

I am also checked for solution posted PropertyValuesHolder: Couldn't find setter/getter for property alpha with value type float

But this solution won't work for me since I am applying the animation to the custom drawable.

Can and one explain what is reason for this error while using ofFloat(....). And what would be the alternate solution of this. Thanks in Advance.

回答1:

Same problem here.

Solved that way:

final ObjectAnimator animScrollToBottom = ObjectAnimator.ofInt(AnimatorProxy.wrap(scrollView), "scrollY", fromPositionInt, toPositionInt).setDuration(500);

or with float values:

final ObjectAnimator animScrollToBottom = ObjectAnimator.ofFloat(scrollView, "y", fromPositionInt,toPositionInt).setDuration(500);