[英]How to avoid Android TalkBack reading SwitchCompat TextOn/TextOff
I have a SwitchCompat with a text that I set via SwitchCompat.setText(). 我有一个SwitchCompat,其中包含我通过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.
问题是Android TalkBack会显示例如“打开,切换,双击...”。setShowText(false)也无济于事。
I think you should use .setContentDescription() instead. 我认为您应该改用.setContentDescription()。
This is the method primarily used for accessibility support. 这是主要用于辅助功能支持的方法。 You can read its documentation here:
您可以在此处阅读其文档:
https://developer.android.com/reference/android/view/View.html#setContentDescription(java.lang.CharSequence) https://developer.android.com/reference/android/view/View.html#setContentDescription(java.lang.CharSequence)
Also, following accessibility guidelines, you shouldn't get rid of the actionable text provided ie "ON double tap to.." 另外,按照可访问性准则,您也不应该放弃所提供的可操作文本,即“双击”。
Hope this helps! 希望这可以帮助!
The solution is to use: 解决方案是使用:
mToggle.setTextOff("");
mToggle.setTextOn("");
Then only the text you set via setText() is being read. 然后,仅读取通过setText()设置的文本。 Don't know if this strange behavior is a bug or works as designed, it doesn't seem right to me though.
不知道这种奇怪的行为是否是错误或按设计工作,但对我来说似乎不正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.