zcweng / SwitchButton

SwitchButton.An beautiful+lightweight+custom-style-easy switch widget for Android,minSdkVersion >= 11
https://github.com/zcweng/SwitchButton
MIT License
2.65k stars 412 forks source link

Disable Animation During RecyclerView Scrolling #62

Open deneme721a opened 3 months ago

deneme721a commented 3 months ago

I don't want the animation to constantly change while scrolling through the RecyclerView. How can I solve this?

I just want it to be animated while I'm checking out. For example switchButton.setChecked(boolean state, boolean animate);

Can you make such a method? @zcweng @IvanAbakumov @msdx I found a solution like this, but it is not healthy at all. I first remove the animation with enable effect and then turn it on during touch, but this is not the right approach. Can you please create a solution like I said?

holder.switchButton.setEnableEffect(false);
holder.switchButton.setChecked(itemModels.get(position).isEnabled());

holder.switchButton.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        holder.switchButton.setEnableEffect(true);
        return false;
    }
});
developmans commented 3 months ago

已收到!

deneme721a commented 3 months ago

Can you add something like this? @zcweng

switchButton.setChecked(boolean state, boolean animate);