如果我将特定的文本作为占位符,为什么Android Talkback不选择此JETPACK构成概述的Textfield?
我正在使用对话测试我的应用程序以兼容兼容性。但是,即使在启用对话的情况下,某些概述的TextFields也被跳过,即使单击对话也是不可选择的。我使用Kotlin/Gradle/Compose创建了一个示例应用程序,以确保与我的项目设置无关。
将“占位符”文本更改为某些值可以选择对话,而其他值则使其无法选择(例如“ mm/dd/yyyy”“使对讲”跳过了字段,但是“ Hello World”允许对话选择该字段)。
代码如下:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
PlaygroundTheme {
// A surface container using the 'background' color from the theme
Column(
modifier = Modifier.fillMaxSize(),
) {
Greeting("Android")
OutlinedTextField(
value = remember{mutableStateOf("")}.value,
onValueChange = {
},
label = {
Text(text = "Date of Birth")
},
placeholder = {
Text(text = "MM/DD/YYYY") //TalkBack won't select the field with this placeholder
// Text(text = "Hello World") //TalkBack WILL select the field with this placeholder
}
)
}
}
}
}
}
@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
}
这是我正在使用的依赖性:
buildscript {
ext {
compose_version = '1.3.0-alpha01'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.playground"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.2.0'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha14'
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0'
implementation 'androidx.activity:activity-compose:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
某些字符串或字符是否被Talkback禁止?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题...我进行了一些测试(使用androidx.compose.ui:ui:ui:1.3.0-
textfield
和OutlinedTextField
之间的行为差异时,我们将占位符
和label
时。 Google的问题跟踪器在这里issuetracker.google.com/issues/242439166“ rel =” nofollow noreferrer”>此处或在这里。我没有其他解决方案,只有仅使用
标签
与OutlinedTextField
使用,因为可访问性对我们来说不是可选的。我在。 a href =“ https://i.sstatic.net/ozqpf.gif” rel =“ nofollow noreferrer“>
I have the same problem... I ran some test (with androidx.compose.ui:ui:1.3.0-beta03):
There is a difference of behavior between
TextField
andOutlinedTextField
when we put aplaceholder
and alabel
. There are some similar issues on Google's issue tracker here, here or here.I found no others solutions than using only
label
with anOutlinedTextField
, as accessibility is not optional for us. I made a new issue on Google's tracker with the following sample I made, and the result:正如@berhug所指出的那样,似乎有一个错误。为了使它阅读内容,您可以通过添加语义修改器来添加内容描述:
这还会导致屏幕读取器添加有关如何在读取文本输入字段的其他说明。
这些链接中有一些有用的附加信息:
https://bryanherbst.com/2020/2020/11/11/03/compose-semantics-talkbackback /
As @BerHug notes, there seems to be a bug. In order to make it read something out you can add a content description by adding a semantics modifier:
This will also cause the screen reader to add the additional instructions on how to activate the text entry field when it reads it out.
There's some useful additional information in these links:
https://developer.android.com/jetpack/compose/accessibility
https://bryanherbst.com/2020/11/03/compose-semantics-talkback/