Search code examples
androidtalkback

How to avoid Android TalkBack reading SwitchCompat TextOn/TextOff


I have a SwitchCompat with a text that I set via SwitchCompat.setText().
In my case this text is only "On" or "Off".

The problem is Android TalkBack will then read for example "On ON, Switch, double tap to...".
Also setShowText(false) doesn't help.


Solution

  • The solution is to use:

    mToggle.setTextOff("");
    mToggle.setTextOn("");
    

    Then only the text you set via setText() is being read. Don't know if this strange behavior is a bug or works as designed, it doesn't seem right to me though.