android - TextView 链接下划线问题
问题描述
任何想法为什么链接上的下划线会超过链接之前的空格字符?您可以看到下划线几乎触及链接之前的字符 r 和 d。
我的文本视图:
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="15dp"
android:text="@string/register_terms"
android:textAlignment="center"
android:textColor="#BFFFFFFF"
android:textColorLink="@android:color/white"
android:textSize="15sp" />
我的字符串:
<string name="register_terms">By clicking this button, you agree to our <a href="https://www.google.com/">Terms & Conditions</a> and <a href="https://www.google.com/">Privacy Policy</a>.</string>
解决方案
您可以在 xml 中将字符串编写为:
<string name="register_terms">By clicking this button, you agree to our <a href="https://www.google.com/">Terms & Conditions</a> and <a href="https://www.google.com/">Privacy Policy</a>.</string>
并在 textview 属性中声明为:android:text="@string/register_terms"
或者您可以将 xml 中的字符串声明为:
<string name="register_terms">By clicking this button, you agree to our <![CDATA[<a href="https://www.google.com/">Terms & Conditions</a>]]> and <![CDATA[<a href="https://www.google.com/">Privacy Policy</a>]]>.</string>
并在活动中用作:
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(Html.fromHtml(getString(R.string.register_terms)));
推荐阅读
- flutter - 将从 Flutter Web 中挑选的图像上传到 Firebase 存储和 Firestore
- javascript - 如何将我的数百张图片链接到我在电子商务网站中的产品?
- php - 使用 XPath 将文本打印到一个元素 - PHP
- mysql - 基于另一个表中的公式的列计算
- google-apps-script - 无法解决服务器上的 Google File Picker ScriptError
- perl - 通过 perlbrew 安装 perl 时如何重新运行测试失败?
- android - 与 TCP、UDP、串行通信时可能出现什么错误?
- javascript - 如何选择多个下拉列表并使用 php 和 jquery 将它们提交到数据库
- php - 不能让用户像“Facebook”一样长时间登录
- javascript - 在某些动态路线中隐藏Angular中的组件