滚动nestedscrollview中的recyclerview时,对讲焦点将移至工具栏项 [英] Talkback focus goes to toolbar items when recyclerview within nestedscrollview is scrolled

本文介绍了滚动nestedscrollview中的recyclerview时,对讲焦点将移至工具栏项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的版式中有一个nestedscrollview,其中包含少量文本,按钮和recyclerviews.

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

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

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.

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

This issue arises only for recyclerviews within nestedscrollview.

我的layout中的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>

我的recyclerview布局是通过以下方式添加的:

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?

推荐答案

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

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

我认为您需要在recyclerView上设置以下属性:

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:

focusable和focusableInTouchMode之间的差异

解释下来的后代(Focusability = afterDescendants)

这篇关于滚动nestedscrollview中的recyclerview时,对讲焦点将移至工具栏项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆