简体   繁体   English

如何避免Android TalkBack读取SwitchCompat TextOn / TextOff

[英]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.

相关问题 Android:Switch上的android:textOn和android:textOff无法正常工作 - Android: android:textOn and android:textOff on Switch not working 在Android Swtich中更改textOn和textOff的位置 - Change Position of textOn and textOff in Android Swtich Android Switch小部件textOn和textOff在Lollipop中不起作用 - Android Switch widget textOn and textOff not working in Lollipop Android Switch小部件textOn和textOff无法正常工作 - Android Switch widget textOn and textOff not working as expected Android切换textOn / Off会阻止从Talkback中读取 - Android toggle textOn/Off prevent reading from Talkback 在Android中以编程方式实现“ android:textOff”和“ android:textOn”属性以用于切换按钮 - implement “android:textOff” & “android:textOn” property for toggle button programatically in Android 如何将ToggleButton的宽度设置为textOn和textOff值的较宽范围? - How to set ToggleButton width to the wider of textOn and textOff values? 如何避免 TalkBack 读取已关闭的片段 - How to avoid TalkBack from reading dismissed fragment ToggleButton的自定义背景隐藏textOn和textOff - Custom background for ToggleButton hides textOn and textOff 切换小部件textOn和textOff文本不以小写形式显示 - Switch widget textOn and textOff text is not appearing in lowercase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM