There is no exact solution to this problem. You can find the reason here.
But there is a little bit of hacky solution that we can use. Take a look at this answer and the Custom SwitchCompatFix.java class.
To make two private methods accessible Java Reflection is used there. Letter, these methods have been used to cancel the animation when triggered. You can use that Custom Switch Class and the code below in order to achieve what you need.
switchCompatFix = findViewById(R.id.switchCompatFix);
switchCompatFix.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
if(!switchCompat.isChecked()) {
switchCompat.setChecked(true, false);
}else {
switchCompat.setChecked(false, false);
}
}
return true;
}
});
By returning true from the onTouch() method, the touch listener will not reach the Parent SwitchComapt class.