| Id | UnlinkedVisibleLabelstoInputs |
| Summary | A visible label is not programmatically connected to its input, so it is not announced |
| Severity | Warning |
| Category | Assistive Technologies / Labels and Associations |
| Affects | Resource files |
| Implementation | Fully covered by Android Lint |
Label elements (typically TextViews) lack the
android:labelFor attribute to programmatically associate them
with their corresponding UI elements or views.
Without proper label associations, assistive technology users cannot easily understand which labels describe which controls or content areas, leading to confusion during navigation, increased errors, and difficulty understanding the relationship between interface elements.
<!-- Label without labelFor association -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email Address:" />
<EditText
android:id="@+id/email_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
<!-- Missing: android:labelFor="@+id/email_field" on TextView -->
<!-- Screen reader cannot associate label with input field -->
class SignupFormActivity : AppCompatActivity() {
private fun setupEmailField() {
val emailLabel = TextView(this).apply {
text = "Email Address:"
// Missing: labelFor = emailField.id
}
val emailField = EditText(this).apply {
id = View.generateViewId()
inputType = InputType.TYPE_TEXT_EMAIL_ADDRESS
}
// TalkBack users cannot understand the relationship
// between "Email Address:" label and the input field
}
}