I have noticed that in many situations android:importantForAccessibility="yes"
can be replaced by android:focusable="true"
and work exactly the same with TalkBack. When should android:importantForAccessibility="yes"
be used instead of using focusable?
Android defines android:importantForAccessibility
as:
Describes whether or not this view is important for accessibility. If it is important, the view fires accessibility events and is reported to accessibility services that query the screen. Note: While not recommended, an accessibility service may decide to ignore this attribute and operate on all views in the view tree. https://developer.android.com/reference/android/view/View.html#attr_android:importantForAccessibility
And android:focusable="true"
as:
Controls whether a view can take focus. By default, this is "auto" which lets the framework determine whether a user can move focus to a view. By setting this attribute to true the view is allowed to take focus. By setting it to "false" the view will not take focus. This value does not impact the behavior of directly calling requestFocus(), which will always request focus regardless of this view. It only impacts where focus navigation will try to move focus. https://developer.android.com/reference/android/view/View.html#attr_android:focusable