| Id | DecorativeElementsAnnouncedAsContent |
| Summary | Decorative or non-functional graphics are exposed as meaningful content, adding noise to screen readers |
| Severity | Informational |
| Category | Assistive Technologies / Content Descriptions |
| Affects | Resource files and Kotlin and Java files |
| Implementation |
Considered by
ContentDescription Android Lint rule, only by ignoring the missing content description check on XML
elements with android:importantForAccessibility attribute
set to no. It does not detect decorative elements that are incorrectly
given a content description. Heuristics, or other solutions could be
considered to potentially find decorative elements that are not
excluded from the accessibility tree (probably decorative Images with
content descriptions, so it could be to find decorative clues (posibly
a list of words) in the id or
contentDescription)
|
Decorative or non-actionable UI elements (backgrounds, animations,
ornamental text) lack proper accessibility exclusion implementation,
either missing
android:importantForAccessibility="no" attribute or
contentDescription="@null", causing them to be included in
the accessibility tree.
Creates navigation inefficiency and cognitive overload for assistive technology users by including non-meaningful elements in the accessibility tree, making it harder to locate and interact with actionable content and significantly slowing down task completion.
<!-- Decorative star icon without proper accessibility exclusion -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Premium Product" />
<!-- Decorative star that gets announced as "Image" -->
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/star_decoration" />
<!-- Missing: android:importantForAccessibility="no" -->
</LinearLayout>
class ProductAdapter : RecyclerView.Adapter<ProductViewHolder>() {
override fun onBindViewHolder(holder: ProductViewHolder, position: Int) {
val product = products[position]
holder.productName.text = product.name
// Adding decorative star without accessibility exclusion
val decorativeStar = ImageView(holder.itemView.context).apply {
setImageResource(R.drawable.star_decoration)
layoutParams = LinearLayout.LayoutParams(16.dpToPx(), 16.dpToPx())
// Missing: importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
}
holder.container.addView(decorativeStar)
// TalkBack will announce this as "Image" unnecessarily
}
}