首页 > 解决方案 > Android CheckBox 设置超链接文字颜色

问题描述

我有一个在文本中有两个链接的 CheckBox。

我通过以下方式设置文本:

String htmlText = "Accept <a href='someUrl'>Terms and Conditions</a> and <a href='anotherUrl'>Privacy Policy</a>";

checkbox.setText(Html.fromHtml(htmlText));
checkbox.setMovementMethod(LinkMovementMethod.getInstance());

这完全可以接受链接文本为白色且我的应用程序背景颜色为白色,因此链接文本不可见但间隙仍然存在,当单击间隙时,它会打开浏览器。

如何更改链接的文本颜色?

我努力了:

String htmlText = "Accept <a style='color:#007CC2;' href='someUrl'>Terms and Conditions</a> and <a style='color:#007CC2;' href='anotherUrl'>Privacy Policy</a>";

但它不起作用。任何帮助将不胜感激 :)。

标签: javaandroidhtmlcssxml

解决方案


我找到了解决方案。

android:textColorLink="你的颜色在这里"


推荐阅读