[英]how to change color of textview hyperlink?
我將此代碼用於超鏈接:
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/hyperlink"
android:text="@string/hyperlink"
android:autoLink="web"/>
默認情況下它顯示藍色,但是如何更改 Android 中超鏈接的顏色?
將android:textColorLink="yourcolorhere"
添加到您的TextView
如果您想以編程方式更改它:
yourText.setLinkTextColor(Color.RED);
您可以在 XML 文件上使用:
android:textColorLink="Code"
“代碼”可以是例如#ff0000
或@color/red
您可以在 JAVA 代碼上使用:
tv.setLinkTextColor(color);
顏色可以是例如Color.RED
或Color.parseColor("#ff0000");
您需要使用android:textColorLink="#000000"
其中000000
是您的顏色的十六進制代碼。 希望能幫助到你。
您也可以打開 colors.xml 並將以下顏色更改為您想要的任何顏色:
<color name="colorAccent">#FF4081</color>
您需要使用android:textColorLink="colorCode"
。 希望它會奏效。
如果有人需要知道這個藍色的十六進制值,那就是#7bc9c2。
我使用滴管來解決這個問題,因為我在任何地方都找不到它,無論如何它不在谷歌調色板上:
https://www.google.com/design/spec/style/color.html#color-color-palette
在TextView
標簽的 xml 文件中:
android:autoLink="web" //link the content of web
android:textColorLink="#FFFFFF" //change the color of the link
將這些代碼行添加到textview
文件中的XML
中,它將正常工作
android:autoLink="web"
android:textColorLink="@android:color/holo_orange_dark"
android:linksClickable="true"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.