Android的 - prevent话语提示从公布的TextView标题大声 [英] Android - prevent TalkBack from announcing TextView title aloud

查看:174
本文介绍了Android的 - prevent话语提示从公布的TextView标题大声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个可访问的Andr​​oid应用程序,人们将利用触摸和话语提示无障碍服务探索用我的应用程序。

这是我的Andr​​oid XML code:

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / LinearLayout中
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>

    <的TextView
        机器人:ID =@ + ID /用的名字
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_marginTop =20dip
        机器人:layout_marginLeft =15dip
        机器人:TEXTSIZE =20SP
        机器人:文本=@字符串/ forenameText
        机器人:contentDescription =@空/>

    <的EditText
        机器人:ID =@ + ID / EditTextForename
        机器人:layout_width =285dp
        机器人:layout_height =65dp
        机器人:layout_marginTop =10dip
        机器人:layout_marginLeft =15dip
        机器人:提示=@字符串/ forenameHint
        机器人:inputType =textPersonName
        机器人:行=1
        机器人:单线=真
        机器人:TEXTSIZE =20SP>
    < /的EditText>

< / LinearLayout中>
 

的strings.xml

 <字符串名称=forenameText>用名字< /串>
<字符串名称=forenameHint>在这里输入你用的名字< /串>
 

TextView中显示标题用的名字和的EditText让我在表单字段中输入一些细节。我的问题是,当我 通过使用触摸浏览拖我的手指在屏幕上,话语提示拿起TextView的称号,并大声宣布其为用的名字。我希望TextView中只显示文本,并没有提供任何声音反馈。

我已经设置contentDescription为@null,你可以从code以上看到的,但话语提示仍宣布用的名字时,我的手指定位在 TextView中。

我也试图在我的Java类设置contentDescription:

  TextView的用的名字=(TextView中)findViewById(R.id.forename);
forename.setContentDescription();
 

不过,我仍然得到了同样的问题。是否有任何其他方式从大声宣布其设置contentDescription为空/空,prevent话语提示?

Java的code:

 公共类MainActivity延伸活动{

    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);

        查看用的名字= findViewById(R.id.forename);

        forename.setAccessibilityDelegate(新AccessibilityDelegate(){
          公共布尔performAccessibilityAction(查看主机,诠释行动,包参数){
            返回true;
          }
        });
    }

}
 

解决方案

我是想今天同样的事情,并能够在像这样一个TextView设置一个'空'contentDescription(使用非打破空白):

  decorativeTextView.setContentDescription(\ u00A0);
 

现在话语提示不出声为TextView的。

但我同意尼克要离开的标签,在你的情况下可读的,因为提示是只读的空EditTexts。

I am developing an accessible android application where people would be using Explore by Touch and TalkBack accessibility services to use my application.

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>

strings.xml

<string name="forenameText">Forename</string>
<string name="forenameHint">Enter your forename here</string>

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.

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.

I have also tried setting contentDescription in my Java class:

TextView forename=(TextView)findViewById(R.id.forename);
forename.setContentDescription("");

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 code:

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;
          }
        });
    }

}

解决方案

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"); 

now TalkBack doesn't say anything for that TextView.

but I agree with Nick about leaving the label as readable in your case, because hint is only read for empty EditTexts.

这篇关于Android的 - prevent话语提示从公布的TextView标题大声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆