Android TV 的無障礙功能最佳做法
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本指南提供 Android TV 無障礙功能的最佳做法,並針對原生和非原生應用程式提出建議。
為什麼無障礙功能對我的 TV 應用程式很重要?
在電視觀眾中,視力障礙者並不少見。
世界衛生組織 (WHO) 估計,全球約有 22 億人有視力障礙。根據 2018 年全國健康訪問調查,美國有 3,200 萬名年滿 18 歲的民眾有明顯的視力障礙。根據歐洲盲人聯盟 (EBU) 的估計,歐洲有 3,000 萬名盲人和弱視者。
最重要的是,視障使用者也能像視力正常者一樣享受媒體內容。根據 Comcast 於 2017 年委託進行的調查,96% 的視障使用者會定期觀看電視,其中 81% 的人每天觀看時間超過一小時。不過,65% 的受訪者也表示,他們在查詢電視節目時遇到問題。此外,在2020 年英國的調查中,有 80% 的身心障礙人士表示,他們在使用隨選視訊串流服務時,曾遇到無障礙問題。
輔助技術可以協助低視能使用者,但為電視應用程式的內容探索歷程提供無障礙支援也很重要。舉例來說,請特別注意提供導覽指引和正確標記元素,並確保電視應用程式能與 TalkBack 等無障礙功能搭配使用。這些步驟可大幅提升視障人士的使用體驗。
改善無障礙程度的第一步是瞭解相關知識。本指南可協助您和團隊找出電視應用程式的無障礙問題。
Android 無障礙資源
如要進一步瞭解 Android 無障礙功能,請參閱無障礙功能開發資源。
文字比例
Android TV 應用程式應支援不同的像素密度,尊重使用者對文字縮放比例的偏好設定。
請特別注意:
您可以使用下列指令變更文字比例:
adb shell settings put system font_scale 1.2f
在 Android 12 以上版本中,使用者可以透過裝置設定變更文字縮放比例。
鍵盤配置
在 Android 13 (API 級別 33) 以上版本中,您可以使用 getKeyCodeForKeyLocation()
查閱預期按鍵位置的鍵碼。如果使用者重新對應了部分按鍵位置,或是使用非標準配置的鍵盤,可能就需要這麼做。
口述影像
在 Android 13 (API 級別 33) 以上版本中,使用者可以透過新的全系統無障礙偏好設定,在所有應用程式中啟用語音說明。Android TV 應用程式可以透過 isAudioDescriptionRequested()
查詢使用者偏好設定。
Kotlin
private lateinit var accessibilityManager: AccessibilityManager
// In onCreate():
accessibilityManager = getSystemService(AccessibilityManager::class.java)
// Where your media player is initialized
if (am.isAudioDescriptionRequested) {
// User has requested to enable audio descriptions
}
Java
private AccessibilityManager accessibilityManager;
// In onCreate():
accessibilityManager = getSystemService(AccessibilityManager.class);
// Where your media player is initialized
if(accessibilityManager.isAudioDescriptionRequested()) {
// User has requested to enable audio descriptions
}
Android TV 應用程式可以將監聽器新增至 AccessibilityManager
,監控使用者偏好設定的變更情形:
Kotlin
private val listener =
AccessibilityManager.AudioDescriptionRequestedChangeListener { enabled ->
// Preference changed; reflect its state in your media player
}
override fun onStart() {
super.onStart()
accessibilityManager.addAudioDescriptionRequestedChangeListener(mainExecutor, listener)
}
override fun onStop() {
super.onStop()
accessibilityManager.removeAudioDescriptionRequestedChangeListener(listener)
}
Java
private AccessibilityManager.AudioDescriptionRequestedChangeListener listener = enabled -> {
// Preference changed; reflect its state in your media player
};
@Override
protected void onStart() {
super.onStart();
accessibilityManager.addAudioDescriptionRequestedChangeListener(getMainExecutor(), listener);
}
@Override
protected void onStop() {
super.onStop();
accessibilityManager.removeAudioDescriptionRequestedChangeListener(listener);
}
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[],[],null,["# Accessibility best practices for Android TV\n\nThis guide provides best practices for accessibility on Android TV and provides\nrecommendations for both native and non-native apps.\n\nWhy is accessibility important for my TV app?\n---------------------------------------------\n\nVision impairments are not uncommon among the TV-watching population.\nAn estimated [2.2 billion people globally](https://www.who.int/health-topics/blindness-and-vision-loss#tab=tab_1)\nhave a vision impairment, according\nto the World Health Organization (WHO). In the US, 32 million Americans age 18 and older have experienced\nsignificant vision loss,\naccording to the [2018 National Health Interview Survey](https://www.afb.org/research-and-initiatives/statistics/adults).\nIn Europe, the estimates\npoint to [30 million](http://www.euroblind.org/about-blindness-and-partial-sight/facts-and-figures#:%7E:text=Statistics,sighted%20persons%20as%20blind%20persons)\nblind and partially sighted persons, according to the European Blind Union (EBU).\n\nMost importantly, users with vision impairments enjoy media content\njust as much as their fully sighted peers. A [2017 survey](https://www.afb.org/research-and-initiatives/statistics/adults) commissioned by Comcast\nshowed that 96% of users who are blind or have low vision regularly watch\nTV, with 81% watching more than an hour per day. However, 65% also reported\nencountering problems with looking up what's on TV. And in a [2020 survey in the\nUK](https://bighack.org/video-on-demand-streaming-and-accessibility-the-big-hack-survey-feedback/),\n80% of disabled people said they had experienced accessibility issues with video\non-demand streaming services.\n\nWhile assistive technologies can and do help users with low vision, it's\nimportant to support accessibility in content discovery journeys for TV apps.\nFor example, pay extra attention to providing navigation guidance and\nproperly labeling elements, and ensure that TV apps work well with accessibility\nfeatures like TalkBack. These steps can significantly improve the experience for\nusers with vision impairments.\n\nThe first step toward improving accessibility is awareness. This guide can\nhelp you and your team to uncover accessibility issues with your TV app.\n\n### Android accessibility resources\n\nTo learn more about accessibility on Android, see our [accessibility development resources](/guide/topics/ui/accessibility).\n\nText scaling\n------------\n\nAndroid TV apps should respect the user's preference for text scaling by [supporting different pixel densities](/training/multiscreen/screendensities#TaskUseDP).\n\nTake special care to:\n\n- Use `wrap_content` for dimensions in UI components.\n- Ensure that layouts rearrange components as their dimensions change depending on the text scale.\n- Ensure that components still fit on the screen at larger text scales.\n- Don't use sp text size units for components that are not flexible.\n- Check the value of `FONT_SCALE` for adjustment in custom views:\n\n // Checking font scale with Context\n val scale = resources.configuration.fontScale\n Log.d(TAG, \"Text scale is: \" + scale)\n\nThe text scale can be changed with the following command: \n\n adb shell settings put system font_scale 1.2f\n\nOn Android 12 and above, users can alter the text scaling from the device\nsettings.\n\nKeyboard layouts\n----------------\n\nIn Android 13 (API level 33) and higher, you can use\n[`getKeyCodeForKeyLocation()`](/reference/android/view/InputDevice#getKeyCodeForKeyLocation(int))\nto\n[look up the keycodes](/training/tv/games#keyboard-layouts) for\nexpected key locations.\nThis might be necessary if the user has re-mapped some key locations or if they\nare using a keyboard that does not have a typical layout.\n\nAudio description\n-----------------\n\nIn Android 13 (API level 33) and higher, a new system-wide accessibility preference\nlets users enable audio descriptions across all apps. Android TV apps can\ncheck the user's preference by querying it with\n[`isAudioDescriptionRequested()`](/reference/android/view/accessibility/AccessibilityManager#isAudioDescriptionRequested()). \n\n### Kotlin\n\n```kotlin\nprivate lateinit var accessibilityManager: AccessibilityManager\n\n// In onCreate():\naccessibilityManager = getSystemService(AccessibilityManager::class.java)\n\n// Where your media player is initialized\nif (am.isAudioDescriptionRequested) {\n // User has requested to enable audio descriptions\n}\n```\n\n### Java\n\n```java\nprivate AccessibilityManager accessibilityManager;\n\n// In onCreate():\naccessibilityManager = getSystemService(AccessibilityManager.class);\n\n// Where your media player is initialized\nif(accessibilityManager.isAudioDescriptionRequested()) {\n // User has requested to enable audio descriptions\n}\n```\n\nAndroid TV apps can monitor when a user's preference changes by\nadding a listener to\n[`AccessibilityManager`](/reference/android/view/accessibility/AccessibilityManager): \n\n### Kotlin\n\n```kotlin\nprivate val listener =\n AccessibilityManager.AudioDescriptionRequestedChangeListener { enabled -\u003e\n // Preference changed; reflect its state in your media player\n }\n\noverride fun onStart() {\n super.onStart()\n\n accessibilityManager.addAudioDescriptionRequestedChangeListener(mainExecutor, listener)\n}\n\noverride fun onStop() {\n super.onStop()\n\n accessibilityManager.removeAudioDescriptionRequestedChangeListener(listener)\n}\n```\n\n### Java\n\n```java\nprivate AccessibilityManager.AudioDescriptionRequestedChangeListener listener = enabled -\u003e {\n // Preference changed; reflect its state in your media player\n};\n\n@Override\nprotected void onStart() {\n super.onStart();\n\n accessibilityManager.addAudioDescriptionRequestedChangeListener(getMainExecutor(), listener);\n}\n\n@Override\nprotected void onStop() {\n super.onStop();\n\n accessibilityManager.removeAudioDescriptionRequestedChangeListener(listener);\n}\n```"]]