代码之家  ›  专栏  ›  技术社区  ›  sadat

持久BottomSheet视图在对讲模式下无法聚焦(辅助功能)

  •  0
  • sadat  · 技术社区  · 4 年前

    我有一个持久的底线 bottom_sheet_persistent.xml

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

    使用底线的活动是

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

    当我打开可访问性的对讲功能并展开底部工作表时,位于底部工作表下方的“活动”中的文本(将与底部工作表的文本视图重叠)将成为焦点。我怎样才能把焦点放在底部(看起来很明显)。我试着让底部页面可以点击,但在这种情况下,整个底部页面都是焦点,而不是单个项目。

    任何帮助或建议!

    0 回复  |  直到 4 年前
        1
  •  0
  •   sadat    4 年前

    底部图纸布局的父视图如下

    <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">
    
        2
  •  0
  •   Dave    4 年前

    我遇到了同样的问题,我明确地解决了调用performAccessibilityAction()的问题。 试试下面这张。

    yourView.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS,null)
    
        3
  •  0
  •   matsem    3 年前

    这个 BottomSheetBehaviour.setUpdateImportantForAccessibilityOnSiblings(Boolean) 就是你想要的。

    当您将其设置为 true ,它基本上告诉辅助功能服务在扩展时忽略BottomSheet下的所有视图,从而允许TalkBack仅关注包含在您的BottomSheet中的视图。