1

I am trying to use TalkBack Accessibility in Canvas object using RectF in RecyclerView item on swipe left to enable delete button, but unable to find solution.

My RecyclerView item has swipe to enable delete button functionality. On Swipe left I am showing Delete button using Canvas object. But in accessibility Talkback mode the delete button is not focused. I want the app to be accessible and want the delete button shown using Canvas and RectF to be focusable. How to proceed? Any guidance is appreciated. Thanks in advance

1 Answers1

-1

If someone's relying on accessibility focus to find and press the delete button, they might have trouble recognising and using the swipe functionality that reveals it. It's probably better to give accessibility users an alternative - there's a nice one in ViewCompat:

ViewCompat.addAccessibilityAction(view, "Delete thing") { _, _ -> doDelete() }

This adds a "Delete thing" action to a context menu on view, which is available to accessibility service users. You can add a few, so they have a simple menu of important actions they can take. So if you put that on the list item itself, they can easily navigate through and delete stuff, favourite it, select it etc - all the actions that are available in that item's UI

You could also disable the swipe functionality, click listeners etc depending on whether accessibility services are active. There's some chat about how to do that here: How to know if Android TalkBack is active?

cactustictacs
  • 17,935
  • 2
  • 14
  • 25
  • Hi, Thank you for the suggesstion. But I am struggling with Accessibility on Virtaul View using ExploreByTouchHelper class in Recycler item swipe – Fluent Sarcasm Apr 28 '21 at 12:25