/documentation/android_access/DesigningForAccessibility.html

http://eyes-free.googlecode.com/ · HTML · 192 lines · 176 code · 4 blank · 12 comment · 0 complexity · e73fda3eb424c0f3473aaa7c148e77ef MD5 · raw file

  1. <!-- Copyright 2010 Google Inc.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License. -->
  11. <html>
  12. <head>
  13. <title>Designing for Accessibility</title>
  14. <link rel="stylesheet" type="text/css" href="style.css">
  15. <style>
  16. .code {
  17. font-style: italic;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <div id="main_body">
  23. <h1>Designing for Accessibility</h1>
  24. <p>Many Android users have disabilities that cause them to interact with
  25. their Android devices in different ways. These include users who have visual,
  26. physical or aging-related disabilities that prevent them from fully using or
  27. seeing a touch screen.</p>
  28. <p></p>
  29. <p>Android provides an accessibility layer that helps these users navigate
  30. their Android devices more easily. These services provide things like
  31. text-to-speech, haptic feedback and trackball/D-pad navigation that augment the
  32. user experience.</p>
  33. <p></p>
  34. <p>Your application should follow these guidelines to assure that it will
  35. provide a good experience for these users.</p>
  36. <h2>Introduction</h2>
  37. <p>Following these two basic rules will solve the majority of access related
  38. problems:</p>
  39. <ol>
  40. <li>Make all of your controls accessible via the trackball or directional
  41. controller.</li>
  42. <li><span class="code"><a
  43. href="http://developer.android.com/reference/android/widget/ImageButton.html">ImageButton</a></span><a
  44. href="http://developer.android.com/reference/android/widget/ImageButton.html">s</a>,
  45. <span class="code"><a
  46. href="http://developer.android.com/reference/android/widget/EditText.html">EditTexts</a></span>
  47. and other input elements using the <span class="code"><a
  48. href="http://developer.android.com/reference/android/view/View.html#attr_android:contentDescription">contentDescription</a></span>
  49. attribute.</li>
  50. </ol>
  51. <h2>Allow Navigation with a Directional Controller</h2>
  52. <p>Many Android devices come with some sort of directional controller, such
  53. as:</p>
  54. <ol>
  55. <li>A clickable trackball that can be moved in arbitrary directions.</li>
  56. <li>A clickable D-pad that provides movement in four directions.</li>
  57. <li>Arrow keys plus a center button that&rsquo;s equivalent to clicking a
  58. trackball or d-pad.</li>
  59. </ol>
  60. <p></p>
  61. <p>All of these types of directional controllers allow users to navigate the
  62. screen without using the touch screen. On some devices, a user can also navigate
  63. to the top or bottom of a list by holding down the alt key while pressing a
  64. discrete key for up or down.</p>
  65. <p></p>
  66. <p>A directional controller is the primary means of navigation for users
  67. with visual and some physical impairments and for devices without a touch
  68. screen. Verify that all important controls are reachable without using the touch
  69. screen and that clicking with the center button has the same effect as clicking
  70. on the element on the touch screen.</p>
  71. <p></p>
  72. <p>The ability to navigate to a particular view with a directional
  73. controller it is determined via the <span class="code"><a
  74. href="http://developer.android.com/reference/android/view/View.html#isFocusable()">isFocusable()</a></span>
  75. method. To change whether a view can take focus, call <span class="code"><a
  76. href="http://developer.android.com/reference/android/view/View.html#setFocusable(boolean)">setFocusable(boolean)</a></span>
  77. or set the <span class="code"><a
  78. href="http://developer.android.com/reference/android/view/View.html#attr_android:focusable">android:focusable</a></span>
  79. attribute in an XML layout file.</p>
  80. <p></p>
  81. <p>The ordering of the focus movement is based on an algorithm which finds
  82. the nearest neighbor in a given direction. In rare cases, the default algorithm
  83. may not match the intended behavior of the developer. In these situations, you
  84. can provide explicit overrides by using these XML attributes in the layout file:</p>
  85. <p class="code">nextFocusDown</p>
  86. <p class="code">nextFocusLeft</p>
  87. <p class="code">nextFocusRight</p>
  88. <p class="code">nextFocusUp</p>
  89. <h3>Clicking with the a directional controller</h3>
  90. <p>On most devices, clicking with a directional controller sends a <span
  91. class="code"><a
  92. href="http://developer.android.com/reference/android/view/KeyEvent.html">KeyEvent</a></span>
  93. with <span class="code"><a
  94. href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DPAD_CENTER">KEYCODE_DPAD_CENTER</a></span>.
  95. Make sure that this event has the same effect as clicking on the element. All
  96. standard Android views already handle <span class="code">KEYCODE_DPAD_CENTER</span>
  97. appropriately.</p>
  98. <p></p>
  99. <p><span class="code">KeyEvent</span> <span class="code"><a
  100. href="http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_ENTER">KEYCODE_ENTER</a></span>
  101. as equivalent to <span class="code">KEYCODE_DPAD_CENTER</span>. That makes
  102. things easier for devices with a full qwerty keyboard.</p>
  103. <h2>Label Your Input Elements</h2>
  104. <p>Many input elements rely on visual cues to inform the user of their
  105. meaning. For example, an application may use an <span class="code"><a
  106. href="http://developer.android.com/reference/android/widget/ImageButton.html">ImageButton</a></span>
  107. with a picture of a plus sign to indicate that the user can add an entry to a
  108. table. Or, an <span class="code"><a
  109. href="http://developer.android.com/reference/android/widget/EditText.html">EditText</a></span>
  110. may have a label near it that indicates its purpose. When a visually impaired
  111. user accesses your application using Android&rsquo;s accessibility services,
  112. these visual cues are often lost.</p>
  113. <p></p>
  114. <p>The <span class="code"><a
  115. href="http://developer.android.com/reference/android/view/View.html#attr_android:contentDescription">contentDescription</a></span>
  116. attribute that should be used to provide a textual representation of this
  117. information. Set this attribute on every <span class="code">ImageButton</span>
  118. and <span class="code">EditText</span> and on any other input widget that might
  119. benefit from this extra information.</p>
  120. <h2>Follow Android UI Best Practices</h2>
  121. <p>Developing a user interface that complies with the Android UI guidelines
  122. will make it easier for users to learn to use your application. This consistency
  123. is especially important for many disabled users, as they may have less
  124. contextual information available to try to understand your application&rsquo;s
  125. interface.</p>
  126. <p></p>
  127. <p>Use the view elements provided by the Android SDK whenever possible, as
  128. these elements have accessibility support built in.</p>
  129. <h2>Send <span class="code">AccessibilityEvents</span> from Custom View
  130. Elements</h2>
  131. <p>If your application requires that you create a custom view element, you
  132. can make your view accessible by implementing the <span class="code"><a
  133. href="http://developer.android.com/reference/android/view/accessibility/AccessibilityEventSource.html">AccessibilityEventSource</a></span>
  134. interface and sending <span class="code"><a
  135. href="http://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html">AccessibilityEvent</a></span>s
  136. at the proper times.</p>
  137. <p></p>
  138. <p>View classes already implement the <span class="code">AccessibiltyEventSource</span>
  139. interface. This interface provides the mechanism for sending events to the
  140. registered AccessibilityServices.</p>
  141. <p></p>
  142. <p>There are five types of accessibility events that should be sent as the
  143. user interacts with your view.</p>
  144. <p></p>
  145. <p class="code">TYPE_VIEW_CLICKED</p>
  146. <p>&nbsp; &nbsp;This should be sent when the user clicks on the view.</p>
  147. <p class="code">TYPE_VIEW_LONG_CLICKED</p>
  148. <p>&nbsp; &nbsp;This should be sent when the user long clicks on the view.</p>
  149. <p class="code">TYPE_VIEW_SELECTED</p>
  150. <p>&nbsp; &nbsp;This should be sent when the selects and item, usually in
  151. the context of an <a
  152. href="http://developer.android.com/reference/android/widget/AdapterView.html">AdapterView</a>.</p>
  153. <p class="code">TYPE_VIEW_FOCUSED</p>
  154. <p>&nbsp; &nbsp;This should be sent when the user focuses on the view.</p>
  155. <p class="code">TYPE_VIEW_TEXT_CHANGED</p>
  156. <p>&nbsp; &nbsp;This should be sent when the text of the view changes.</p>
  157. <p></p>
  158. <p>Each event type requires that particular properties be set, so that the
  159. accessibility service can properly respond to the event. Those specifics are
  160. detailed in the <span class="code">AccessibilityEvent</span> documentation.</p>
  161. <h2>Test Your Application&rsquo;s Accessibility</h2>
  162. <p>You can simulate the experience for many users by enabling an
  163. accessibility service that will speak as you move about the screen. One such
  164. service is <a
  165. href="http://market.android.com/details?id=com.google.android.marvin.talkback">TalkBack</a>,
  166. by the Eyes-Free Project. It comes preinstalled on many Android devices, but is
  167. also available for free download in the Android Market.</p>
  168. <p></p>
  169. <p>This service requires that you have a text-to-speech engine installed on
  170. your phone. You can verify if you have one installed in the <span class="code">Text-to-speech</span>
  171. settings menu by selecting <span class="code">Listen to an example</span>. If
  172. you do not hear anything spoken, install the required voice data using the <span
  173. class="code">Install voice data</span> option.</p>
  174. <p></p>
  175. <p>Once text-to-speech is functioning correctly, you can enable TalkBack in
  176. the <span class="code">Accessibility settings</span> menu. Enable both
  177. Accessibility and TalkBack. As you navigate about the device, you should now
  178. hear spoken feedback.</p>
  179. <p></p>
  180. <p>You can now attempt to use your application as a blind user would. As you
  181. move around using only the directional controller, make sure that the spoken
  182. feedback hear makes sense and is sufficient to navigate the application without
  183. any visual cues.</p>
  184. </div>
  185. </body>
  186. </html>