Non-Focusable Interactive Control

Id NonFocusableInteractiveControl
Summary Interactive controls cannot receive focus using keyboard or switch input, blocking access
Severity Warning
Category Assistive Technologies / Focus and Navigation
Affects Resource files and Kotlin and Java files
Implementation Fully covered by KeyboardInaccessibleWidget Android Lint rule

Symptom

Interactive UI elements that should be focusable lack explicit android:focusable="true" or have improper importantForAccessibility="no" attribute.

Rationale

May prevent assistive technologies from properly accessing interactive elements, especially in complex layouts or custom components.

Examples

XML Layout Example

<!-- Clickable TextView without focusable attribute -->
<TextView
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:text="Tap to expand details"
    android:clickable="true"
    android:background="?android:attr/selectableItemBackground" />
    <!-- Missing: android:focusable="true" -->
    <!-- Switch navigation cannot reach this element -->

Kotlin Code Example

class ProductListActivity : AppCompatActivity() {

    private fun setupExpandableItem() {
        val expandText = TextView(this).apply {
            text = "Tap to expand details"
            isClickable = true
            setOnClickListener { expandDetails() }
            // Missing: isFocusable = true
        }

        // Switch navigation and keyboard users cannot reach this element
        // Only touch users can interact with it
    }
}

GitHub issues under this tag