3

When I have a recycler view with 12 items, when accessibility focus goes onto cell number 3, for example, talkback announces "Double tap to activate. Item 3 of 12".

I want to keep the action but stop it from announcing the item position and item count. How can I do this? I have tried to assign a delegate to the recycler view but not sure what to override in the delegate.

How can I do this?

pnizzle
  • 6,243
  • 4
  • 52
  • 81

2 Answers2

2

So I figured it out. An AccessibilityNodeInfo has a method called SetCollectionInfo(). CollectionInfo has properties like rowCont and columnCount. I simply set the info to null.

Note, the below is xamarin:

    private class TabLayoutTabAccessibilityDelegate: View.AccessibilityDelegate
    {
        public override void OnInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info)
        {
            base.OnInitializeAccessibilityNodeInfo(host, info);
            info.SetCollectionInfo(null);
        }
    }
pnizzle
  • 6,243
  • 4
  • 52
  • 81
  • It didn't help with `BottomNavigationView`. After reading my own content description, it adds: "tab ExampleTitle1 one of four". – Dr.jacky Nov 17 '21 at 16:43
0

This is a functionality that should not be disabled: it lets people using Talkback know that they are in a list, how long is the list, which element is currently focused (are there more elements above/below).

sigute
  • 1,143
  • 12
  • 21
  • 2
    It can be disabled, because sometimes you want to implement your own messages that tell the user that they are in a list and that the items are unique in some way, like a table of unique IDs does not need to announce the cell position. Have a look here: https://developer.android.com/guide/topics/ui/accessibility/principles#collection. Your point is valid though. Im just saying it should be, and can be overriden, see my answer :) – pnizzle May 11 '21 at 06:44
  • 1
    Make sure the list can still be scrolled via Talkback after this change: setting collection info to null will remove these announcements, but will also break other behaviour, like automatically scrolling to the items not on screen when user reaches them. – sigute May 11 '21 at 07:56
  • You are right on that. It certainly does inhibit other collection related behaviour. I only explored this as an experiment. There must be a less destructive approach. Perhaps some properties off the CollectionInfo objet? – pnizzle May 12 '21 at 05:24
  • I have never been able to figure it out without breaking other functionality :/ – sigute May 12 '21 at 06:17