我有以下TextView:
<TextView android:id="@+id/theFooBar"
android:autoLink="web"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/fooBar"
android:textColor="@android:color/black"
android:textSize="20sp"/>和字符串:
<string name="fooBar">Foo <u>bar</u>.</string>这给出了带下划线的黑色文本。如果我想要蓝色的、无下划线的文本作为链接( "bar“部分),但我希望其他部分( "foo”部分)是黑色的,该怎么办?我怎样才能做到这一点呢?
发布于 2011-05-14 07:54:00
在这种情况下,我建议您使用WebView而不是TextView:
WebView web = (WebView) findViewById(R.id.theFooBar);
String str = "<font color='blue'>bar</font><font color='black'><u>foo</u></font>";
web.setBackgroundColor(0);
// It will sets the background color from white to transparent.
web.loadData(str, "text/html", "utf8");发布于 2013-12-12 20:17:58
在TextView中添加android:textColorLink来定义链接的文本颜色
https://stackoverflow.com/questions/5998618
复制相似问题