gpt4 book ai didi

android - Jetpack Compose Focus Order with Talkback

转载 作者:行者123 更新时间:2023-12-05 03:37:50 30 4
gpt4 key购买 nike

按照文档: https://developer.android.com/reference/kotlin/androidx/compose/ui/focus/package-summary#(androidx.compose.ui.Modifier).focusOrder(kotlin.Function1)

我想为 Column 设置自定义焦点顺序。

我已经按照文档为每个项目设置了不同的焦点请求者,并指定要关注的项目 next,但似乎 Talkback 忽略了我的元素的焦点顺序。

这是一个例子:

                val focusRequesters = remember { List(4) { FocusRequester() } }
Column {
Text("Line 1",
Modifier
.focusOrder(focusRequesters[0]) {
next = focusRequesters[2]
down = focusRequesters[2]
right = focusRequesters[2]
}
.focusable())
Text("Line 2",
Modifier
.focusOrder(focusRequesters[1]) {
next = focusRequesters[0]
down = focusRequesters[0]
right = focusRequesters[0]
}
.focusable())
Text("Line 3",
Modifier
.focusOrder(focusRequesters[2]) {
next = focusRequesters[3]
down = focusRequesters[3]
right = focusRequesters[3]
}
.focusable())
Text("Line 4",
Modifier
.focusOrder(focusRequesters[3]) {
next = focusRequesters[1]
down = focusRequesters[1]
right = focusRequesters[1]
}
.focusable())
}

尝试了 nextdownright 和每个单独的组合,但似乎没有任何改变 Accessibility 遍历顺序。

最佳答案

如果您使用 LocalFocusManager 更改它,焦点顺序将被考虑在内,如下所示:

LocalFocusManager.current.moveFocus(FocusDirection.Next)

但这与可访问性无关。似乎 android:accessibilityTraversalAfter 对应物在 Compose 中尚不可用,请关注 this issue了解详情。

关于android - Jetpack Compose Focus Order with Talkback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69149021/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com