13

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?

jneander
  • 1,150
  • 14
  • 34
  • Maybe try calling `clearAnimation` after setting the state? – Buddy Nov 23 '15 at 17:29
  • No dice. Based on what I have read in similar issues, the animation is not a first-class Android Animation, but rather a part of the Style for relevant Views in the Lollipop API. Unsuccessful attempts to manipulate Animation effects seem to support that. – jneander Nov 23 '15 at 17:36
  • Have the same issue on Reyclerview. The animation is causing the scroll to lag because lot's of checkboxes in the list can be checked by default and bindviewholder triggers all these animations the same time you are scrolling.. – Jordy Nov 23 '15 at 20:18

2 Answers2

23

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

roelvogel
  • 734
  • 6
  • 10
  • https://stackoverflow.com/questions/42997873/android-checkboxes-not-checked-correctly-in-viewpager-with-data-binding Also solved this – Girish Apr 13 '19 at 16:04
1

Try this

<CheckBox
    
    **android:background="@android:color/transparent"

    **android:clickable="false"

    android:id="@+id/login_access_tick"
    
    android:layout_width="wrap_content"
    
    android:layout_height="wrap_content"/>

Hope it helps.Thanks

touhid udoy
  • 4,005
  • 2
  • 18
  • 31