Table of Contents
Handling Non-readable Content in Android
A practical guide on making emojis, special characters, and text-in-images accessible through proper content descriptions and TalkBack-compatible implementations.
π― Why It Matters
The impact on accessibility can be significant. Screen readers might mispronounce words, skip content, or read out nonsensical strings, leading to a frustrating and confusing experience for users with visual impairments.
π» Implementation
Correct Code Example: Providing Text Alternatives
Demo Description
Here is an example of providing a content description for an image:
imageView.contentDescription = "Smiling face emoji"Code Explanation
This Kotlin code sets the `contentDescription` of an `ImageView` to "Smiling face emoji," providing a textual description of the image for accessibility purposes.
Incorrect Code Example: Neglecting Emoji Descriptions
Demo Description
Here is an example of not providing a description for an emoji:
// No description for the emoji
textView.text = "I \u2764\uFE0F Android! "Code Explanation
This Kotlin code sets the `TextView` text to "I β€οΈ Android! " without adding a description for the emoji, which might affect accessibility for users relying on screen readers.
Correct Code Example: Providing Emoji Descriptions
Demo Description
Here is how to provide clear descriptions for emojis:
val text = "I \u2764\uFE0F Android!"
textView.text = text
textView.contentDescription = "I love Android!"Code Explanation
This Kotlin code sets the text of a `TextView` and provides a `contentDescription` of "I love Android!" for accessibility purposes.
Correct Code Example: Handling Special Characters
Demo Description
Here is how to provide context for special characters or symbols:
val mathEquation = "E = mcΒ²"
textView.text = mathEquation
textView.contentDescription = "E equals m c squared"Code Explanation
This Kotlin code sets the `TextView` text to "E = mcΒ²" and provides a `contentDescription` of "E equals m c squared" for accessibility, giving a detailed description of the equation.
Correct Code Example: Describing Text in Images
Demo Description
Here is how to provide thorough descriptions for text in images:
imageView.setImageResource(R.drawable.welcome_banner)
imageView.contentDescription = "Black Friday special offer. 50 percent off selected items"Code Explanation
This Kotlin code sets an image resource (`welcome_banner`) to an `ImageView` and provides a `contentDescription` of "Black Friday special offer. 50 percent off selected items" for accessibility purposes.
β Best Practices
Do's
- βProvide clear, descriptive text alternatives for all emojis and special characters
- βUse plain language that conveys the meaning, not just the visual appearance
- βExtract text from images and provide it as alternative text
- βTest with screen readers to verify content is announced correctly
- βProvide context for mathematical notation and symbols
- βMark purely decorative elements as inaccessible to avoid clutter
Don'ts
- βRely on emojis alone to convey critical information
- βEmbed important text in images without alternatives
- βUse vague descriptions like "emoji" or "symbol"
- βForget to describe compound emojis or emoji sequences
- βUse custom fonts without ensuring screen reader compatibility
- βAssume screen readers will correctly pronounce special characters
π Common Pitfalls
Missing Emoji Descriptions
Emojis without `contentDescription` are either skipped or read as character codes, leaving users confused about the content
Text Embedded in Images
Essential information in images is invisible to screen readers without proper alternative text
Vague Accessibility Labels
Generic descriptions like "image" or "icon" provide no useful context to users
Undescribed Special Characters
Mathematical symbols, currency signs, and other special characters may be mispronounced or skipped entirely
Assuming Universal Emoji Meanings
Emojis can have different cultural interpretations, so clear descriptions are essential
Over-Describing Decorative Elements
Making every visual element accessible creates unnecessary clutter for screen reader users
TalkBack
Will read the `contentDescription` attribute instead of attempting to interpret emojis or special characters. Without descriptions, TalkBack may skip content or read character codes
Switch Control
Users navigating with switches rely on clear labels to understand element content
Dynamic Type
Text alternatives should scale appropriately with the user's text size settings
π§ͺ Testing Steps
- 1Use TalkBack: Enable TalkBack in Settings β Accessibility β TalkBack
- 2Navigate through content: Swipe right to move between elements
- 3Listen to how content is read: Verify emojis, special characters, and images are announced correctly
- 4Test with various languages and scripts: Switch system language and retest
- 5Verify emoji and special character descriptions: Ensure descriptions convey accurate meaning
- 6Test text in images: Confirm all embedded text is properly described
- 7Check mathematical notation: Verify symbols are announced correctly
Become a member to read this solution, and all of Ma11y.
This resource is part of our member knowledge base. Log in or create an account to unlock:
- Complete accessibility guidance and implementation examples
- Curated compliance frameworks and checklists
- Early access to new tools and features
