Android - 阻止 TalkBack 大声宣布 TextView 标题 [英] Android - prevent TalkBack from announcing TextView title aloud
问题描述
我正在开发一个可访问的 android 应用程序,人们将在其中使用通过触摸探索和 TalkBack 可访问性服务来使用我的应用程序.
I am developing an accessible android application where people would be using Explore by Touch and TalkBack accessibility services to use my application.
这是我的 Android XML 代码:
This is my Android XML code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/forename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:layout_marginLeft="15dip"
android:textSize="20sp"
android:text="@string/forenameText"
android:contentDescription="@null"/>
<EditText
android:id="@+id/EditTextForename"
android:layout_width="285dp"
android:layout_height="65dp"
android:layout_marginTop="10dip"
android:layout_marginLeft="15dip"
android:hint="@string/forenameHint"
android:inputType="textPersonName"
android:lines="1"
android:singleLine="true"
android:textSize="20sp" >
</EditText>
</LinearLayout>
字符串.xml
<string name="forenameText">Forename</string>
<string name="forenameHint">Enter your forename here</string>
TextView 显示标题Forename",EditText 允许我在表单字段中输入一些详细信息.我遇到的问题是,当我使用触摸浏览"在屏幕上拖动我的手指,TalkBack 会拾取 TextView 的标题并将其大声宣布为Forename".我希望 TextView 只显示文本而不提供任何声音反馈.
TextView displays the title "Forename" and EditText allows me to enter some details in the form field. The problem I have is that when I drag my finger across the screen by using Explore by Touch, TalkBack picks up the title of the TextView and announces it aloud as "Forename". I want the TextView to only display text and not provide any audible feedback.
我已将 contentDescription 设置为 @null,正如您从上面的代码中看到的那样,但是当我的手指位于文本视图.
I have set contentDescription to @null as you can see from the code above, but TalkBack still announces "Forename" when my finger is located over the TextView.
我也尝试在我的 Java 类中设置 contentDescription:
I have also tried setting contentDescription in my Java class:
TextView forename=(TextView)findViewById(R.id.forename);
forename.setContentDescription("");
但是,我仍然遇到同样的问题.有没有其他方法可以将 contentDescription 设置为 null/empty 并阻止 TalkBack 大声宣布它?
However, I still get the same problem. Is there any other way to set contentDescription to null/empty and prevent TalkBack from announcing it aloud?
Java 代码:
public class MainActivity extends Activity{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View forename = findViewById(R.id.forename);
forename.setAccessibilityDelegate(new AccessibilityDelegate() {
public boolean performAccessibilityAction (View host, int action, Bundle args){
return true;
}
});
}
}
推荐答案
我今天也在尝试做同样的事情,并且能够在 TextView<上设置
'empty'
contentDescription/code> 像这样(使用不间断的空格):
I was trying to do the same today, and was able to set an 'empty'
contentDescription on a TextView
like so (using a non-breaking whitespace):
decorativeTextView.setContentDescription("u00A0");
现在 TalkBack
对那个 TextView
什么都不说.
now TalkBack
doesn't say anything for that TextView
.
但我同意尼克关于在您的情况下将标签保留为可读的观点,因为提示仅针对空 EditTexts
读取.
but I agree with Nick about leaving the label as readable in your case, because hint is only read for empty EditTexts
.
这篇关于Android - 阻止 TalkBack 大声宣布 TextView 标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!