I have an activity that has a fragment. That fragment gets the accessibility focus correctly. But when a replace the first fragment with another one, the second one is not getting the focuse automatically, I have to touch the fragment to get the focus.
This is the way a do the replace:
val fragmentTransaction = supportFragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.container, myFragment)
fragmentTransaction.commit()
container.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
I try to add the android:importantForAccessibility
and the android:clickable="true"
to the second fragment (the one that is not getting accessibility focus)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:importantForAccessibility="yes">
...
</LinearLayout>
I also try to use the add fragment instead of replace with the same result.
Thanks!