Switch Text disable tapping

383 views Asked by At

Is there anyway to disable tapping on the text of a Switch? Currently it toggles the switch which I don't want.

I'm setting my switch text like messageSwitch.setText("Messaging Enabled");. This makes the entire switch view receiving taps of the event. Is there any way to disable this?

1

There are 1 answers

0
Janpan On

In your xml, just set it like this:

android:clickable="false"

or this might be better

android:clickable="false"
android:focusable="false"
android:enabled="false"

Setting the enabled option to false disables both the text and the switch itself. You can do all of this programatically as well.