TriStateToggleButton icon indicating copy to clipboard operation
TriStateToggleButton copied to clipboard

Toggle MidColor error

Open theonardo23 opened this issue 8 years ago • 2 comments

I set my colors as following : midColor = #878787 offColor = #1ABC9C onColor = #F98162

For on State and off State it's working really good, but when I call toggleMid() it shows something like below selection_062

It's a great library anyway

theonardo23 avatar Oct 31 '17 05:10 theonardo23

Having the same issue.

IanWambai avatar May 29 '18 10:05 IanWambai

I was finally able to figure out why this issue occurs. onToggle I was immediately updating my list again which redrew the switch mid-animation so the switch couldn't finish colouring the animation. I fixed this by using a Handler like this:

//This fixes the animation of the switch
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
     @Override
       public void run() {
          //Do your switch stuff

           notifyDataSetChanged();
         }
   }, 500);

I've found that 500ms is the optimal time, any less and you'll still mess up the animation. Setting the animation to off doesn't help either. One issue with this fix is that if the switch is toggled really fast, there'll be a slight delay in processing the input.

IanWambai avatar Jun 12 '18 09:06 IanWambai