Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle MidColor error #2

Open
theonardo23 opened this issue Oct 31, 2017 · 2 comments
Open

Toggle MidColor error #2

theonardo23 opened this issue Oct 31, 2017 · 2 comments

Comments

@theonardo23
Copy link

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

@IanWambai
Copy link

Having the same issue.

@IanWambai
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants