I am facing a problem in Android 13 where there is a scenario when a page is loaded, the user needs to access the elements by the keyboard for navigation.
When the page gets loaded it focus appears on the element but the selection does not show upon the element. So, as a result user needs to press Tab key twice to get selection back on that element.
It is working fine on Android 12 or below but facing the issue in Android 13.
Below are the codes:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@android:color/white">
<include
android:id="@+id/language_toolbar"
layout="@layout/toolbar_simple"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/language_list"
android:layout_width="@dimen/size_0dp"
android:layout_height="@dimen/size_0dp"
android:layout_below="@id/language_toolbar"
android:divider="#000"
android:dividerHeight="@dimen/size_2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/language_toolbar" />
</androidx.constraintlayout.widget.ConstraintLayout>
toolbar_simple.xml
<androidx.appcompat.widget.Toolbar 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="?android:attr/actionBarSize"
android:background="@android:color/white"
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp"
android:contentInsetEnd="0dp"
android:contentInsetRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
android:touchscreenBlocksFocus="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_toolbar_menu_back"
android:layout_width="@dimen/size_50dp"
android:layout_height="match_parent"
android:clickable="true"
android:contentDescription="@string/cl_toolbar_menu_back"
android:focusable="true"
android:importantForAccessibility="yes"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_toolbar_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:background="@drawable/ic_back_menu"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_toolbar_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:accessibilityHeading="true"
android:fontFamily="@font/roboto_medium"
android:textColor="@color/gray1"
android:textSize="@dimen/text_20"
android:textStyle="normal"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@id/cl_toolbar_menu_back"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_toolbar_menu_offline"
android:layout_width="@dimen/size_50dp"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentEnd="true"
android:layout_gravity="end"
android:contentDescription="@string/cl_toolbar_menu_offline"
android:focusable="true"
android:focusedByDefault="true"
android:nextFocusLeft="@id/app_bar_toolbar_second_level"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_toolbar_menu_offline"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="@drawable/ic_offline_indicator_badge"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_toolbar_save"
android:layout_width="@dimen/size_50dp"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="end"
android:layout_marginEnd="@dimen/size_20dp"
android:fontFamily="@font/roboto_medium"
android:gravity="center"
android:text="@string/save"
android:textColor="@color/gray1"
android:textSize="@dimen/text_16"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_toolbar_skip"
android:layout_width="@dimen/size_50dp"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="end"
android:layout_marginEnd="@dimen/size_20dp"
android:fontFamily="@font/roboto_medium"
android:gravity="center"
android:text="@string/skip"
android:textColor="@color/blue"
android:textSize="@dimen/text_16"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.appcompat.widget.Toolbar>