Missing Heading Role for Titles

Id MissingHeadingRoleforTitles
Summary Section titles lack a heading role, preventing quick navigation
Severity Warning
Category Assistive Technologies / Semantic Roles and States
Affects Resource files and Kotlin and Java files
Implementation Custom lint rule – detect header-like views (e.g., large/bold TextViews, or those styled as section headers) that lack an accessibility heading designation

Symptom

Header elements lack proper accessibility heading designation (through AccessibilityUtils.enableAccessibilityHeading() (View system) or equivalent implementation, such as .semantics { heading() } in Jetpack Compose), preventing them from being recognized as navigational landmarks by assistive technologies.

Rationale

Prevents efficient content navigation for assistive technology users who rely on heading navigation to quickly jump between sections, forcing them to traverse content linearly and significantly increasing time to locate specific information.

Examples

XML Layout Example

<!-- Section header without accessibility heading designation -->
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Account Settings"
    android:textSize="20sp"
    android:textStyle="bold" />
    <!-- Missing android:accessibilityHeading="true" -->

Kotlin Code Example

class SettingsFragment : Fragment() {
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val sectionHeader = view.findViewById<TextView>(R.id.section_header)
        // Missing: AccessibilityUtils.enableAccessibilityHeading(sectionHeader)
        sectionHeader.text = "User Profile"
    }
}

GitHub issues under this tag