2

I have an Expandable ListView contains CheckBoxes in both groupViwes and groups childViews. When having one/more checkBox checked, it causes a re-draw effect on expanding/collapsing any of the groupViews of the listView, please check the following:

enter image description here

As you see, when collapsing group KG-1 after expanding, the group grade 5 is being shifted up to a new position, which gives a bad flickering effect of the group named 1 as it (and its child) takes a while to re-draw the unchecked state as it took the position of a checked group which is grade 5.

So, how to get rid of that re-draw effect? or even to delay the collapse if that would solve the problem.

Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118
  • See https://stackoverflow.com/questions/33876792/temporarily-disable-animation-on-lollipop-checkbox?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa or similar . In my opinion an easier way to do it use a custom check box which has no animation . – ADM Apr 22 '18 at 11:56
  • @ADM actually, doesn't know how, but disabling the animation like mentioned in the answer in the provided link, did solve the problem, you can quote it and add as answer if you want, thank you very much. – Muhammed Refaat Apr 22 '18 at 12:37
  • 1
    Its quite similar to `setChecked(bolean checked, boolean shouldAnimate)` . The whole idea was to skip the animation. That's why it worked . – ADM Apr 22 '18 at 12:54

1 Answers1

2

Call jumpDrawablesToCurrentState() on CheckBox right after calling setChecked(). It will skip the state change animation of CheckBox.

checkBox.setChecked(false);
checkBox.jumpDrawablesToCurrentState();
ADM
  • 20,406
  • 11
  • 52
  • 83