[英]Send accessibility events not linked to any composable in Jetpack compose
Trying to announce accessibility when showing a pop up/Dialog.在显示弹出窗口/对话框时尝试宣布可访问性。 After hours of searching found the following code but this does not work for jetpack compose.经过数小时的搜索,找到了以下代码,但这不适用于 jetpack compose。
Looking for something similar to the code given below but in Jetpack Compose寻找类似于下面给出的代码但在Jetpack Compose中的东西
if (manager.isEnabled) {
val e = AccessibilityEvent.obtain()
e.eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT
e.className = ChangePassword::class.java.name
e.packageName = context.packageName
e.text.add(errorMessage)
manager.sendAccessibilityEvent(e)
}
For all those looking for an answer, there's one simple property in Jetpack Compose that will work.对于所有寻找答案的人来说, Jetpack Compose中有一个简单的属性可以使用。 Which is liveRegion
哪个是liveRegion
You can find the documentation here: https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/LiveRegionMode您可以在此处找到文档: https ://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/LiveRegionMode
and it can be used as follow;它可以按如下方式使用;
Text(modifier = Text(
text = "Page Title,
color = White,
modifier = Modifier
.focusable()
.clearAndSetSemantics {
this.contentDescription = accSkipPermission
liveRegion = LiveRegionMode.Assertive
}
))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.