Home » Android » android – how to change color of textview hyperlink?

android – how to change color of textview hyperlink?

Posted by: admin March 10, 2020 Leave a comment

Questions:

I am using this code for hyperlink:

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/hyperlink" 
    android:text="@string/hyperlink"
    android:autoLink="web"/>

By default it is showing blue color, but how do I change color of hyperlink in Android?

How to&Answers:

Add android:textColorLink="yourcolorhere" to your TextView

Answer:

If you want to change it programmatically:

yourText.setLinkTextColor(Color.RED);

Answer:

You can use on your XML file:

android:textColorLink="Code" 

the “Code” can be e.g. #ff0000 or @color/red

You can use on your JAVA code :

tv.setLinkTextColor(color);

The color can be e.g Color.RED or Color.parseColor("#ff0000");

Answer:

You need to use the android:textColorLink="#000000" where 000000 is your color’s hex code. Hope it helps.

Answer:

You can also open colors.xml and change the following color to whatever you want:

<color name="colorAccent">#FF4081</color>

Answer:

If anyone needs to know the hex value for this blue it is #7bc9c2.

I used Eye Dropper to figure this out as I couldn’t find it documented anywhere, it isn’t on the Google Color Palatte anyway:

https://www.google.com/design/spec/style/color.html#color-color-palette

Answer:

You need to use android:textColorLink="colorCode" . Hope it will work.

Answer:

In xml file of TextView tag :

android:autoLink="web" //link the content of web  
android:textColorLink="#FFFFFF" //change the color of the link 

Answer:

Add these Lines of code to your textview in XML file and it will work perfectly fine

android:autoLink="web"
 android:textColorLink="@android:color/holo_orange_dark"
 android:linksClickable="true"