Split paragraphs in TextView for better readback

Viewed 248

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?

2 Answers

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

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.

Related