I have an ImageView in the layout with content description = 'Close'. When Talkback is turned on, it says "Close button, out of list". Why does Talkback say 'out of list' in addition and how can I avoid it? P.S. there is also a RecyclerView in the layout, maybe it affects somehow.
3 Answers
When accessibility focus is in a list (like a RecyclerView
) it adds "in list" when describing the item, so the user knows where they are. When you move out of the list (say by tapping on your image) it adds "out of list" to say you've moved out of the list.
Generally you don't want to mess with TalkBack's announcements, they're there to help with accessibility, and users are used to hearing standard phrases like that. If you change them it becomes less consistent and potentially confusing.
The exception is adding information, say by adding a description for the action, so instead of "double tap to activate" it says something more useful like "double tap to confirm your choices". There's an example of that here: https://buffer.com/resources/announce-actions/

- 17,935
- 2
- 14
- 25
-
1This is the correct answer and should be marked as such, thanks for the info. Especially for pointing out that one should not mess with TalkBacks default announcements. (Some clients think it would be good to do so, and as a dev, it is important to point out why we should keep this as Google intended it ;-) – Luigi_Papardelle Mar 01 '22 at 14:33
In some cases, this problem can be "solved" by throwing away most of the AccessibilityEvents like this:
fun RecyclerView.setupAccessibilityForRecycler() {
val delegate: AccessibilityDelegateCompat = object : AccessibilityDelegateCompat() {
override fun onRequestSendAccessibilityEvent(
host: ViewGroup,
child: View,
event: AccessibilityEvent
): Boolean {
if (event.eventType != AccessibilityEvent.TYPE_VIEW_FOCUSED) return false
return super.onRequestSendAccessibilityEvent(host, child, event)
}
}
ViewCompat.setAccessibilityDelegate(this, delegate) }
It can be applied on any ViewGroup, not just RecyclerView. It will throw away all those "in list", "out of list", "press select to activate", etc. and keep just what you have put into the contentDescription of the focused item. It can have some negative consequences obviously, so be sure to test it thoroughly. And be sure you really want to disable those standard accessibility messages.

- 61
- 4
I was also facing a similar issue and I found a workaround for this. I used accessibility delegation to re-request accessibility focus on the Image button when it gets the accessibility focus. Here is my code:
My layout file looks something like this.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/iv_close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/back_button_text"
android:paddingHorizontal="20dp"
android:paddingVertical="20dp"
android:src="@drawable/ic_back_arrow"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_close_button" />
</androidx.constraintlayout.widget.ConstraintLayout>
I used the following code snipped in my fragment:
iv_close_button.accessibilityDelegate = object : View.AccessibilityDelegate() {
override fun performAccessibilityAction(
host: View?,
action: Int,
args: Bundle?
): Boolean {
if (action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
// Sends an accessibility event of accessibility focus type.
host?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED)
}
return super.performAccessibilityAction(host, action, args)
}
}
Hopefully, this will work for you too.

- 233
- 4
- 18