Search code examples
androidaccessibility

Persistent BottomSheet Views do not get focus in Talkback mode on (Accessibility)


i have a persistent bottomsheet like 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>

And the activity where the bottomsheet has been used is

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

When I turn on the talkback of accessibility and the bottom sheet is expanded, the text in Activity (will be overlapped by the botttomsheet's textview) which is underneath the bottomsheet gets the focus. How can I get the focus which in on the bottomsheet (seems to be so obvious). I tried to make the bottomsheet clickable, but in that case, the whole bottomsheet gets the focus not the individual items.

Any help or suggestions!


Solution

  • The bottom sheet layout's parent view will be like this

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