java - 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>";
但它不起作用。任何帮助将不胜感激 :)。
解决方案
我找到了解决方案。
android:textColorLink="你的颜色在这里"
推荐阅读
- laravel - Laravel Jetstream(Livewire)没有通过雄辩的关系返回用户
- linux - 无法更新 WSL 分发包
- mysql - mysql aurora high innodb_buffer_pool_reads on a write heavy db instance
- docker - 像 Linux-bash 一样做 PowerShell 推荐(例如 docker)
- bash - Shell脚本调用将输入传递给期望来自终端的输入的命令
- reactjs - ReactJS fetch() 组件安装后,更改时
- java - 我如何从 Jmeter 中的另一个线程接收变量
- mysql - MySQL 中的语法错误:尝试使用 varchar 创建表
- java - 如果程序仅通过 doClick() 进行交互,则 JFrame 永远不会呈现;
- nlp - 我不明白 .text 在 spacy 代码中的目的是什么