更改组合屏幕的默认可访问性焦点
当屏幕显示时,我正在尝试将默认焦点从左上角更改为可不同的组合。我试图获得对讲,以读取更远的文本,而不是左上角的按钮。
@Composable
fun Screen() {
val requester = FocusRequester()
Column {
Top()
Bottom(requester)
}
SideEffect {
requester.requestFocus()
}
}
@Composable
fun Top() {
Row{
Button(onClick = {}) {
Text(text = "top left")
}
Button(onClick = {}) {
Text(text = "top right")
}
}
@Composable
fun Bottom(requester: FocusRequester) {
Column {
Text(
text = "Text to read",
modifier = Modifier
.focusRequester(requester)
.focusable(true)
.focusTarget()
)
}
}
如果使用启动效应,并且preestfocus调用延迟为550。我怀疑requestFocus是在撰写阶段调用的,因此屏幕上没有绘制“抓取”请求,例如,请访问requestFocus调用。在抽奖阶段被调用。
I am trying to change the default focus from the top left to a different composable when the screen displays. I am attempting to get Talkback to read the text that is further down instead of the top-left button.
@Composable
fun Screen() {
val requester = FocusRequester()
Column {
Top()
Bottom(requester)
}
SideEffect {
requester.requestFocus()
}
}
@Composable
fun Top() {
Row{
Button(onClick = {}) {
Text(text = "top left")
}
Button(onClick = {}) {
Text(text = "top right")
}
}
@Composable
fun Bottom(requester: FocusRequester) {
Column {
Text(
text = "Text to read",
modifier = Modifier
.focusRequester(requester)
.focusable(true)
.focusTarget()
)
}
}
This code will work if a LaunchedEffect is used and the requestFocus call is delayed for 550. I suspect the requestFocus is called during the compose phase, and so there is nothing drawn to the screen yet for the request to "grab onto", like if it was called after the draw phase.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论