'Why is the talkback text for a TextView read twice and the hint read as well even if the TextView is filled?

I am working on a large project, where we use TextViews to show text as well as a hint.

When using talkback (accessibility), I have noticed that the hint on a TextView is read twice.

Also even when there is text in the TextView, the hint will still be read.

When I use an EditText instead, only the second problem persists (text entered, hint is still read). This seems to be normal (but confusing) Android-behaviour, since Google-Apps like the PlayStore do this as well.

But why is the TextView reading the hint twice, while an EditText is not?


PS: I am aware of the possibility to switch from TextView to EditText, but since we are using custom views as well that heavily depend on TextView, this is not a feasible option.

I am also aware of using label for, but I am more interested in the technical background why TextView reads the hint twice.

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="test"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

Accessibility is read twice



Solution 1:[1]

It's announcing twice because you're setting the 'hint' to the TextView since it reads its own text as a content description, and 'hint' is being used as text when there is no text set. I think it's not being handled correctly in the TextView.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ray Schwarz