0

I have a TextView with maxLines="1" and a long string of text set to it. ellipsize="end" truncates the text after 1 line, but the talkback, goes on the read the entire text which is not visible in the TextView.

                   <TextView
                    android:id="@+id/tv_title"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:text="@{titleText}" />

Can I restrict the talkback to reading only the text that is visible in the TextView rather than reading the entire text?

Mayur More
  • 951
  • 2
  • 15
  • 37

1 Answers1

1

You can use android:contentDescription to override what Talkback announces for the TextView. You can't really determine how much text is visible before the ellipses because the user might set the fontsize to be bigger in their accessibility settings, causing less text to be displayed before the ellipses, but if you know the text you want to read, you can set it in contentDescription.

I would be cautious about doing this, though. The ellipsize is mainly a visual feature to let the user know there's more text to display than can fit on the screen. If the screen were bigger (or the text shorter), then all of it would be displayed. Screen reader users don't really care if the text can fit on the screen or not and will typically want to hear the entire text.

slugolicious
  • 15,824
  • 2
  • 29
  • 43
  • Thanks @slugolicious. I am aware of the contentDescription method. Although, I was hoping if there was some standard way of implementing this. But looks like there aren't many options around handling ellipsized text with talkback. – Mayur More Dec 09 '21 at 06:33
  • I wanted to state the obvious answer first :-). Your OP didn’t say you had tried `contentDescription`. – slugolicious Dec 09 '21 at 20:04