'Font color set with Html.fromHtml cannot render the color after upgrading Android Studio to Bumblebee
I have an app with rich html text that was working fine. But recently I decided to update the gradle library SDK as mandated by Google. After the update I discovered that colors in the texts had disappeared.I tried everything within my knowledge to get the form of the app back but no to avail. The colors and other formatting refused to show
The below is my code
From NewActivity
TextView mBrandNewDesc = findViewById(R.id.textView);
//get text in text textView
mBrandNewDesc.setText(Html.fromHtml(newDescription));
From String.xml
<string-array name="newbrandDesc">
<item>"<![CDATA[<p><br /><strong>1. </strong><span style="color: #0000FF;"><em>mf</em> </span>All creatures <br />Lift up your voice<br />All praise,<br />with golden beam,<br />softer gleam,<br /><span style="color: #0000ff;"><em>f</em> </span><em>O praise Him, O praise Him</em><br /><em>All Praise</em></p>
<p><br /><strong>2.</strong> Rushing winds so strong<br />clouds that sai along,<br />All praise<br /><span style="color: #0000ff;"><em>cr</em></span> in praise rejoice,<br /><span style="color: #0000ff;"><em>dim</em></span> You lights of evening sing a song.</p>
<p><br /><span style="color: #0000ff;"><em>Breaming, tt ]</em></span></p> ]]>"</item>
</string-array>
I'm using these dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'com.google.android.ads.consent:consent-library:1.0.8'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
I tried using HtmlCompat.fromHtml but it never worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
