首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >持久化BottomSheet视图不会在Talkback模式下获得焦点(可访问性)

持久化BottomSheet视图不会在Talkback模式下获得焦点(可访问性)
EN

Stack Overflow用户
提问于 2022-03-09 01:53:36
回答 3查看 497关注 0票数 1

我有一个持久化的底片,如bottom_sheet_persistent.xml

代码语言:javascript
运行
复制
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottomSheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:behavior_hideable="false"
    app:behavior_peekHeight="80dp"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="230dp"
        android:background="#2196F3"
        app:layout_constraintTop_toTopOf="parent" >

        <TextView
            android:text="Text in Bottom Sheet"
            android:layout_width="match_parent"
            android:textSize="24sp"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

使用底表的活动是

代码语言:javascript
运行
复制
<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">

        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#E7E7E7"
            app:layout_constraintTop_toTopOf="parent">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="bottom"
                android:paddingBottom="200dp"
                app:layout_constraintTop_toTopOf="parent" >
    
                <TextView
                    android:text="Text in Activity"
                    android:textSize="24sp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>
            </LinearLayout>
    
            <include
                android:id="@+id/bottomSheet"
                layout="@layout/bottom_sheet_persistent" />
        </androidx.coordinatorlayout.widget.CoordinatorLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>

当我打开可访问性的对讲机并展开底部工作表时,活动中的文本(将被瓶装工作表的文本视图重叠)获得焦点。我如何才能把焦点放在底部(似乎是如此明显)。我试着使底部页可点击,但在这种情况下,整个底纸得到的焦点,而不是个别的项目。

任何帮助或建议!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2022-03-10 22:58:00

底部工作表布局的父视图如下所示

代码语言:javascript
运行
复制
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottomSheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:behavior_hideable="false"
    app:behavior_peekHeight="80dp"
    android:focusable="true"
    android:importantForAccessibility="no"
    android:clickable="true"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
票数 0
EN

Stack Overflow用户

发布于 2022-04-08 06:22:33

我也遇到了同样的问题,并将其显式地调用了performAccessibilityAction()。在下面的床单上试试这个。

代码语言:javascript
运行
复制
yourView.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS,null)
票数 0
EN

Stack Overflow用户

发布于 2022-09-15 15:20:34

BottomSheetBehaviour.setUpdateImportantForAccessibilityOnSiblings(Boolean)就是你要找的东西。

当您将其设置为true时,它基本上告诉辅助功能服务在展开时忽略BottomSheet下的所有视图,允许TalkBack只聚焦包含在底部工作表中的视图。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71403470

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档