Temporarily disable animation on Lollipop CheckBox

2019-04-21 13:47发布

问题:

I have a ListView with rows that include CheckBoxes. This ListView has filtering behavior attached, which recycles those rows by setting new data (via a simple setData() method) as the filter criteria changes. When this occurs, any recycled row that has the checked state changed will update its CheckBox, which in turn triggers the Lollipop animation of the CheckBox being drawn in or out.

The ways in which this is distracting to the user are numerous. How can this animation be disabled temporarily when its state is programmatically updated?

回答1:

Calling jumpDrawablesToCurrentState() on your CheckBox right after calling setChecked will skip the animation.