滚动nestedscrollview中的recyclerview时,对话焦点将移到工具栏上

问题描述 投票:4回答:1

我的布局中有一个nestedscrollview,其中包含少量文本,按钮和recyclerviews。

启用对讲功能后,我可以遍历所有元素。但是我面临一个问题。当滚动我的水平recyclerview时,然后我轻扫以听到对讲时,焦点将移至工具栏的第一项。然后,我需要遍历所有可见项以到达水平scrollview滚动项。

此问题仅在nestedscrollview中的recyclerviews中出现。

我的布局中的nestedscrollview以这种方式添加:

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

        //my contents

</androidx.core.widget.NestedScrollView>

以这种方式添加了我的recyclerview布局:

<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>

这是预期的行为还是问题,如何解决?

android android-recyclerview android-nestedscrollview talkback android-accessibility
1个回答
0
投票

这里是我最后提供的第一个链接的引文,我认为这与您的问题有关:

“在触摸模式下,没有焦点,也没有选择。用户进入触摸模式后,网格列表中的任何选定项目都将被取消选择。类似地,当用户进入触摸模式时,所有已聚焦的窗口小部件都将变为未聚焦。 ”

我认为您需要在recyclerView上设置这些属性:

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

如果您需要更多信息,请阅读:

Difference between focusable and focusableInTouchMode

explain descendantFocusability = afterDescendants

© www.soinside.com 2019 - 2024. All rights reserved.