[英]How to implement android intermediate progressbar accessibility
I would like to announce the loading text on an android intermediate progressbar.我想在 android 中间进度条上宣布加载文本。 I want to output something like this for disabled people who are using talkback service on the Android device when an intermediate progressbar is loading.
我想为在加载中间进度条时在 Android 设备上使用对讲服务的残疾人输出类似的内容。
I checked around google and found that I could use:我查了一下谷歌,发现我可以使用:
1) announceForAccessibility on progressbar view. 1) 进度条视图上的announceForAccessibility。 (Not working in my case, only works when I load it with a Handler)
(在我的情况下不起作用,只有当我用处理程序加载它时才有效)
My code我的代码
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onResume() {
super.onResume()
val progressbar: ProgressBar = findViewById(R.id.testProgressBar)
// progressbar.announceForAccessibility("My name is Neo "); // not working
Handler().postDelayed(object : Runnable {
override fun run() {
progressbar.announceForAccessibility("My name is Neo ");
}
}, 1000)
}
Do you guys have any other suggestion to solve this kind of problem?你们有没有其他建议来解决这种问题? I wonder how people got working at so many places https://www.programcreek.com/java-api-examples/?class=android.view.View&method=announceForAccessibility
我想知道人们是如何在这么多地方工作的https://www.programcreek.com/java-api-examples/?class=android.view.View&method=announceForAccessibility
Thanks for your help.谢谢你的帮助。
You could try a polite android:accessibilityLiveRegion
, which would ensure that TalkBack does not interrupt something already being announced:您可以尝试礼貌的
android:accessibilityLiveRegion
,这将确保 TalkBack 不会中断已经宣布的内容:
<ProgressBar
android:id="@+id/testProgressBar"
…
android:accessibilityLiveRegion="polite" />
More here: Using a Live Region更多信息: 使用实时区域
Make your progressbar focusable and then send custom content description based on your requirement.使您的进度条可聚焦,然后根据您的要求发送自定义内容描述。 Talkback will handle that for you.
Talkback 将为您处理。
public void showProgresSBarWithCustomDescription(val contentDesc) {
progressBar.contentDescription = contentDesc
progressBar.visibility = View.VISIBLE
}
//Add following properties to progressbar
android:focusable="true"
android:focusableInTouchMode="true"
android:importantForAccessibility="yes"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.