0
I have the following text stated in xml string.:
<string name="TITLE_EXAMPLE"><![CDATA[
<p>Para entrar em contato com nossa Central:</p>
<p><b>Brasil: Capitais</b></p>
<p> <a href="tel:+5541123123123" style="color:#E29800"> 5541123123123</a> </p>
]]>
</string>
How do I apply a certain color to ahref ?
Even with style is not working!
[EDIT]
At the suggestion of aldeir Psr :
TextView contact = findViewById(R.id.contact);
String html;
contact.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSIONS_CODE.N) {
html = Html.fromHtml(getString(R.string.codeHtml), FROM_HTML_OPTION_USE_CSS_COLORS);
} else {
html = Html.fromHtml(getString(R.string.codeHtml));
}
contact.setText(html);
Works only on versions of N upward!
I would like to apply in all versions!
And for versions below the N? can be done tbm?
– Thiago Luiz Domacoski
You can. Just use
String html = Html.fromHtml(getString(R.string.codeHtml));
– Valdeir Psr
didn’t work in below the N
– Thiago Luiz Domacoski
Check this lining with the font. https://stackoverflow.com/a/25011685
– Valdeir Psr
Valdeir Psr, it didn’t work either! So, I realized that he uses the colorAccent for this color, so I created a Theme with <item name="colorAccent">@color/green</item> and applied to Textview, temporarily suits me, but I will research more about it! Thank you!
– Thiago Luiz Domacoski