Android - prevent TalkBack from announcing TextView title aloud

后端 未结 6 476
北恋
北恋 2020-12-06 10:59

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

相关标签:
6条回答
  • 2020-12-06 11:23

    I had a similar problem. I eventually solved it by using the setAccessibilityDelegate method and overriding View.AccessibilityDelegate's performAccessibilityAction method.

    try this:

    View forename = findViewById(R.id.forename);
    
    forename.setAccessibilityDelegate(new AccessibilityDelegate() {
      public boolean performAccessibilityAction (View host, int action, Bundle args){
        return true;
      }
    });
    
    0 讨论(0)
  • 2020-12-06 11:24

    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.

    0 讨论(0)
  • 2020-12-06 11:27

    For better backwards compatibility:

    ViewCompat.setImportantForAccessibility(
            decorativeTextView,
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);
    
    0 讨论(0)
  • 2020-12-06 11:34

    Why do you not want the TextView to speak "forename"? It is being used as a label for the EditText. Once the user has entered some text the hint "enter your forename here" would no longer be spoken - as far as I know - so the TextView given the user some context for the EditText.

    Similarly the announcement of "editbox" gives the user the role of the EditText control. While "form field" might be better it would not be the same behavior as in other apps and in the OS.

    0 讨论(0)
  • 2020-12-06 11:46

    Since API 16, Android introduced the following:

    android:importantForAccessibility="no"
    

    or

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO)
    

    Which allows developers to disable talkback all together for certain views.

    http://developer.android.com/reference/android/view/View.html

    0 讨论(0)
  • 2020-12-06 11:47

    I had the same problem, and the only thing that worked for me was android:contentDescription=" " (white space).

    0 讨论(0)
提交回复
热议问题