如何从Android strings.xml中的锚链接中删除格式
我有一个包含如下HTML链接的字符串:如何从Android strings.xml中的锚链接中删除格式,android,css,textview,android-xml,Android,Css,Textview,Android Xml,我有一个包含如下HTML链接的字符串: <string name="text_with_link"><a href="openDocument://document1.html"><b>This</b></a> and <a href="openDocument://document2.html"><b>this</b></a> are links</string> tv =
<string name="text_with_link"><a href="openDocument://document1.html"><b>This</b></a> and <a href="openDocument://document2.html"><b>this</b></a> are links</string>
tv = (TextView) findViewById (R.id.textviewid);
tv.setText(Html.fromHtml(getResources.getString(R.string.text_with_link)));
。。但是没有运气。CSS在Android字符串中似乎不起作用。您必须使用
Html.fromHtml
进行格式化,才能像这样工作:
<string name="text_with_link"><a href="openDocument://document1.html"><b>This</b></a> and <a href="openDocument://document2.html"><b>this</b></a> are links</string>
tv = (TextView) findViewById (R.id.textviewid);
tv.setText(Html.fromHtml(getResources.getString(R.string.text_with_link)));
此外,要更改链接颜色,您必须在文本视图XML中使用android:textColorLink
属性来更改链接颜色
CSS在android字符串中不起作用。您能给出您使用的确切代码吗?ex可能会有帮助,这样做仍然只将单词连接在一起,没有任何空格。@anoniim您可以将结果发布为图像吗?对不起,我混淆了我的两个问题,忽略我的最后一条评论。无论如何,在Html中包装文本后,将忽略.fromHtml()。所以没有文字装饰,也没有链接。非常令人惊讶。