Missing Alternative Text for Informative Elements

Id MissingAlternativeTextforInformativeElements
Summary Informative elements lack textual descriptions, preventing screen readers from conveying their purpose
Severity Warning
Category Assistive Technologies / Content Descriptions
Affects Resource files and Kotlin and Java files
Implementation Fully covered by ContentDescription Android Lint rule

Symptom

Interactive or informative elements lack the android:contentDescription attribute, preventing assistive technologies from providing meaningful information about the element's purpose or content.

Rationale

Without content descriptions, assistive technology users cannot understand the purpose, function, or context of UI elements, creating barriers to navigation and task completion. This particularly impacts users who rely on non-visual interaction methods to understand interface components.

Examples

XML Layout Example

<!-- Favorite button without content description -->
<ImageButton
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:src="@drawable/ic_favorite_outline" />
    <!-- Missing: android:contentDescription="Add to favorites" -->
    <!-- TalkBack announces: "Button" (not helpful) -->

Kotlin Code Example

class ArticleAdapter : RecyclerView.Adapter<ArticleViewHolder>() {

    override fun onBindViewHolder(holder: ArticleViewHolder, position: Int) {
        val article = articles[position]

        val favoriteButton = holder.itemView.findViewById<ImageButton>(R.id.favorite_button)
        favoriteButton.setImageResource(R.drawable.ic_favorite_outline)
        favoriteButton.setOnClickListener { toggleFavorite(article) }

        // Missing: favoriteButton.contentDescription = "Add to favorites"
        // TalkBack will announce: "Button" (unhelpful for users)
        // User cannot understand what this button does
    }
}

GitHub issues under this tag