Redundant Placeholder on Static Element

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

Symptom

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.

Rationale

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.

Examples

XML Layout Example

<!-- 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) -->

Kotlin Code Example

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"
    }
}

GitHub issues under this tag