Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Android focusable and importantForAccessibility when using TalkBack?

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

like image 918
Kade Avatar asked Jul 25 '17 16:07

Kade


1 Answers

Focusable refers to "input focus" and "keyboard focus". A focusable control is one which can receive input focus (the cursor), or keyboard focus... which basically means that a user can use the trackball/keyboard navigation to highlight and interact with such controls with the "select" action... example: hitting enter on the keyboard.

isImportantForAccessibility refers to Accessibility Focus. This is highly linked to input focus, but is very different. For example, input focusing "informative" text only content is non sensical. However, allowing a paragraph to receive accessibility focus is VERY important. This allows users using TalkBack to focus and hear the spoken feedback for such informative controls.

If a user is using keyboard navigation, input focus and accessibility focus will be the same, but if a user is using TalkBack swipe navigation, input focus and accessibility focus can be different.

For example:

The cursor could be in an EditText box, while accessibility focus is on the paragraph below it explaining to the user through VoiceFeedback what that control is for.

like image 116
ChrisCM Avatar answered Oct 14 '22 22:10

ChrisCM