Reputation: 1552
I have a strange one, I am using text to speech in my app which works perfectly apart from the fact that it reads out some of the Html code from my formatted string.
Example:
<string name="Aggression">
<![CDATA[
<p><b>Identifying Obsessive Behaviours</b></p>
]]>
</string>
When reading out the string it ignores "< p >" and "< / p >" but reads out the bold tags!
So my question is, any ideas to stop it reading out some html tags?
P.S Im using CDATA due to the length of some of the strings used and formatting issues.
Upvotes: 4
Views: 1203
Reputation: 1552
Ok so I found a pretty amazing workaround. My goal was to still display perfectly formatted html style text which was easy to maintain yet have a text-to-speech engine read out the string for accessibility.
My TextView still used this to display the html formatted text:
contentTextView.setText(Html.fromHtml(content));
My text-to-speech function now uses this which strips all of the tags and headers out and only reads the bare text:
String editedTextReadable = android.text.Html.fromHtml(content).toString();
Upvotes: 3