Android 文本视图链接下划线问题

Android 文本视图链接下划线问题,android,textview,Android,Textview,你知道为什么链接上的下划线在链接前面的空格上吗?您可以看到下划线几乎接触到链接r和d之前的字符 我的文本视图: <TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="5dp" android:

你知道为什么链接上的下划线在链接前面的空格上吗?您可以看到下划线几乎接触到链接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 &amp; Conditions</a> and <a href="https://www.google.com/">Privacy Policy</a>.</string>
单击此按钮,表示您同意我们的和。

这里有一个链接,指向“我的帮助”为您提供的答案:

他们详细解释了如何在字符串中使用
CDATA
来使用
HTML
标记,以及如何使用
HTML.fromHtml()
方法来设置文本

以下是一个例子:

活动中使用
Html.fromHtml()
设置文本

TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(Html.fromHtml(getString(R.string.link)));
textView.setMovementMethod(LinkMovementMethod.getInstance());
在strings.xml中,修改如下:

<string name="link">Test <![CDATA[<a href="#">link</a>]]></string>
测试

希望对您有所帮助:)

您可以用xml将字符串编写为:

<string name="register_terms">By clicking this button, you agree to our&#160;<a href="https://www.google.com/">Terms &amp; Conditions</a> and <a href="https://www.google.com/">Privacy Policy</a>.</string>
<string name="register_terms">By clicking this button, you agree to our <![CDATA[<a href="https://www.google.com/">Terms &amp; 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)));