为了在我的 android 应用程序的页面上显示超链接,我正在这样做:
MyProgram.java
link1.setText(Html.fromHtml(linkText1));
link1.setMovementMethod(LinkMovementMethod.getInstance());
TextView link = (TextView) findViewById(R.id.textView2);
String linkText = "Visit the <a href='http://www.mydomain.com'>My Website</a> web page.";
link.setText(Html.fromHtml(linkText));
link.setMovementMethod(LinkMovementMethod.getInstance());
// Place email address
TextView email = (TextView) findViewById(R.id.textView3);
String emailText = "Contact Me: <a href=\"mailto:myname@mydomain.com\">myname@mydomain.com</a>";
email.setText(Html.fromHtml(emailText));
email.setMovementMethod(LinkMovementMethod.getInstance());
我的程序.XML
<TextView android:text="TextView" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="30dp"></TextView>
<View
android:layout_width="fill_parent"
android:layout_height="30dp">
</View>
<TextView android:text="TextView" android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:textSize="30dp"></TextView>
如果您在我的 XML 中看到,我已尝试将颜色更改为黑色 (android:textColor="#000000"),但我仍然没有看到超链接有任何变化。它仍然是默认颜色,即蓝色
有什么帮助吗?
最佳答案
你应该使用另一个属性:
android:textColorLink="#000000"
关于android - 如何在android中更改超链接的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6928157/