8

I have one large TextView, which is a larger amount of HTML text depending on what is being displayed.

Even though all of the content is in a single TextView, I want the paragraphs contained inside the view to be separate Talkback items. They are HTML formatted with the <p> tag

Right now, it reads everything at once

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam consequat, magna a ornare pharetra, diam arcu rhoncus elit, at consectetur arcu lectus nec nulla.

Ut hendrerit id ante ac lobortis. Morbi ante quam, malesuada eget lobortis vel, porttitor ac felis. Quisque diam purus, dignissim id eros ac, semper mollis elit.

Vivamus iaculis mollis suscipit. Vivamus vel posuere ipsum, et accumsan lectus. Donec tincidunt justo orci, eget molestie sem tempor sed. Duis quis lorem neque.

But I would like it to be broken up without breaking the text out of TextView into a list.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam consequat, magna a ornare pharetra, diam arcu rhoncus elit, at consectetur arcu lectus nec nulla.

Break

Ut hendrerit id ante ac lobortis. Morbi ante quam, malesuada eget lobortis vel, porttitor ac felis. Quisque diam purus, dignissim id eros ac, semper mollis elit.

Break

Vivamus iaculis mollis suscipit. Vivamus vel posuere ipsum, et accumsan lectus. Donec tincidunt justo orci, eget molestie sem tempor sed. Duis quis lorem neque.

Is this possible to do within one TextView?

Tyler
  • 19,113
  • 19
  • 94
  • 151

2 Answers2

0

Try this..

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                mTxtBio.setText(Html.fromHtml(ProfileVal.getBio(), Html.FROM_HTML_MODE_COMPACT));
            } else {
                mTxtBio.setText(Html.fromHtml(ProfileVal.getBio()));
            }

            mTxtBio.setLineSpacing(3, 1.3f);
Manish Ahire
  • 550
  • 4
  • 19
-2

I'm not an android developer so this might be a stupid idea but can a TextView have nested TextViews so that the nested TextViews have each sentence separately?

I'm also a little confused about what's displayed in the TextView. Usually plain text is displayed but it sounds like you are displaying HTML? Or are you formatting the text using HTML in order to get linebreaks and such?

Screen readers usually read the entire contents of an element when it's focused. With a large chunk of text in a TextView, all of it would be read (which is what you're trying to avoid). A screen reader user has the ability to navigate sentence by sentence or paragraph by paragraph (or even character by character or word by word) so you don't really have to force things to be read separately.

slugolicious
  • 15,824
  • 2
  • 29
  • 43
  • You are correct but in kiosk mode, people are suggesting having more content descriptions instead of what is displayed on the screen. – Roll no1 Apr 13 '22 at 09:18
  • @Rollno1 I'm not following that comment. I know what kiosk mode is but I don't follow the *"content description"* part. You want to hear more than what is displayed? Meaning extra content that is only surfaced to screen reader users? That's easily done but you first have to decide if the hidden text that screen readers announce would benefit other users too. If so, then that hidden text should be visible to everyone. – slugolicious Apr 13 '22 at 19:15
  • Android ecosystem provides contentDescription element for each view which is used to speak extra information related to that view and the same will not be visible to any user. – Roll no1 Apr 14 '22 at 09:01
  • @Rollno1 Yes I'm familiar with the `contentDescription` attribute but wasn't sure how that tied into the original question. – slugolicious Apr 14 '22 at 19:58