Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Talkback focus goes to toolbar items when recyclerview within nestedscrollview is scrolled

I have a nestedscrollview within my layout which contains few texts, buttons and recyclerviews.

When talkback is on, I am able to traverse through all elements. But I face an issue. When my horizontal recyclerview is scrolled and then I swipe to hear the talkback, the focus moves to the toolbar first item. Then I need to traverse through all the visible items to reach to the horizontal scrollview scrolled item.

This issue arises only for recyclerviews within nestedscrollview.

My nestedscrollview in layout is added in this manner:

<androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        //my contents

</androidx.core.widget.NestedScrollView>

My recyclerview in layout is added in this manner:

<LinearLayout
     android:id="@+id/photosLL"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">

     <androidx.recyclerview.widget.RecyclerView
          android:id="@+id/photosRV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          tools:listitem="@layout/list_item_photo" />
</LinearLayout>

Is this expected behaviour or if its an issue, how to solve the same?

like image 340
Anju Avatar asked Oct 16 '22 04:10

Anju


1 Answers

Here is a quote from the first link I offered at the end, which I think is relevant to your problem:

"In touch mode, there is no focus and no selection. Any selected item in a list of in a grid becomes unselected as soon as the user enters touch mode. Similarly, any focused widgets become unfocused when the user enters touch mode."

I think what you need is to set these attributes on your recyclerView:

 android:focusableInTouchMode="true"
 android:descendantFocusability="beforeDescendants"

If you are looking for more information, read:

Difference between focusable and focusableInTouchMode

and

explain descendantFocusability = afterDescendants

like image 104
Sina Avatar answered Oct 27 '22 00:10

Sina