4

When a view has event click and enable talkback. I need to disable the audio "double to tap" in the view.

I am using accessibility in android development.

How can I do this, please?

fah127
  • 151
  • 1
  • 1
  • 11
  • 1
    Do you mean the "Double tap to activate" that TalkBack calls out for clickable elements? There's probably no good way to disable this - why would you want to? It's there to let a user know that the control is interactive, and not say static non-clickable text. – BrendanMcK Nov 02 '16 at 01:00
  • 2
    Hi, there is a possible way to disable the accessibility on the android views, like as: `android:importantForAccessibility = "no" ` – fah127 Mar 11 '17 at 05:37
  • @fah127 Great. Thx – KoreanXcodeWorker Aug 14 '17 at 16:10

4 Answers4

13

If you check google talkback source code at this line and here, string resource ("double tap") has been used here and here

So, you should remove AccessibilityActionCompat.ACTION_CLICK action and set isClickable to false in node info.

ViewCompat.setAccessibilityDelegate(view, object : AccessibilityDelegateCompat() {
        override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
            super.onInitializeAccessibilityNodeInfo(host, info)
            info.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK)
            info.isClickable = false
        }
    })

I tested this and it should work.

kiran puppala
  • 689
  • 8
  • 17
0

Use

ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() {
        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            info.addAction(AccessibilityNodeInfoCompat.ACTION_FOCUS);
        }
});

See more detail at https://stackoverflow.com/a/47875696/1915831

Rubin Yoo
  • 2,674
  • 2
  • 24
  • 32
0

Kiran's answer was really helpful, but still some of my devices were adding "double tap and hold to long press" or etc. I just wanted to read my whole paragraph and add "Double tap to activate" only. So I wrote like this;

ViewCompat.setAccessibilityDelegate(<YOUR_TEXTVIEW>, object : AccessibilityDelegateCompat() {
            override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
                super.onInitializeAccessibilityNodeInfo(host, info)
                info.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK)
                info.isClickable = false
                info.isLongClickable = false
                info.text = "${<YOUR_TEXTVIEW>.text}\n" + "Double tap to activate."
                host.isLongClickable = false
            }
        })
Wicaledon
  • 710
  • 1
  • 11
  • 26
-1

For disabling you need to use setClickable(false). !!!And if you use setOnClickListener() on the View, audio "double to tap" will appears again

zayn1991
  • 174
  • 10