| Id | RedundantPlaceholderonStaticElement |
| Summary | Placeholder attribute is used on a static element, resulting in duplicated content announcements |
| Severity | Warning |
| Category | Assistive Technologies / Labels and Associations |
| Affects | Resource files and Kotlin and Java files |
| Implementation | Custom lint rule - detect inappropriate hint attribute usage in TextView elements |
TextView elements inappropriately use android:hint attribute
(intended for input fields) alongside android:text, causing
screen readers to announce the same information twice since both contain
identical values.
Creates inefficient navigation experience for assistive technology users
by duplicating identical information in announcements. The
hint attribute is conceptually inappropriate for static
TextView elements (designed for input guidance in EditText), leading to
unnecessary verbosity.
<!-- TextView inappropriately using hint attribute -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Settings"
android:text="Settings" />
<!-- TalkBack announces: "Settings, Settings" (redundant) -->
<!-- Should only use: android:text="Settings" (no hint needed for static labels) -->
class SettingsActivity : AppCompatActivity() {
private fun setupSettingsLabel() {
val settingsLabel = findViewById<TextView>(R.id.settings_label)
settingsLabel.text = "Settings"
settingsLabel.hint = "Settings" // Inappropriate for static labels
// TalkBack announces: "Settings, Settings" (redundant)
// Should only set: settingsLabel.text = "Settings"
}
}