Overridden Input Handling Breaking Semantics

Id OverriddenInputHandlingBreakingSemantics
Summary Custom input logic replaces native event handling, removing accessibility hooks
Severity Warning
Category Assistive Technologies / Custom Views and Implementation
Affects Kotlin and Java files
Implementation Fully covered by Android Lint

Symptom

Custom click/touch handling (e.g., overriding OnClickListener, onTouchEvent, or implementing custom gestures) prevents screen readers and other assistive technologies from recognizing or activating interactive items. As a result, users relying on accessibility tools cannot interact with these elements.

Rationale

Default Android click events are accessible to screen readers and switch access. Overwriting them without properly forwarding or handling accessibility actions breaks expected behavior, making interactive elements unusable for assistive technology users

Example

Kotlin Code

class CustomButton : View {
    override fun onTouchEvent(event: MotionEvent): Boolean {
        // Custom touch handling
        if (event.action == MotionEvent.ACTION_DOWN) {
            performAction()
            return true
        }
        // Missing: accessibility support
        return false
    }
}

GitHub issues under this tag