jak zmienić kolor hiperłącza textview?

Używam tego kodu do hiperłącza:

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

Domyślnie wyświetlany jest niebieski kolor, ale jak zmienić kolor hiperłącza w Androidzie?

Author: Paul Lammertsma, 2011-07-20

8 answers

Dodaj android:textColorLink="yourcolorhere" do swojego TextView

 532
Author: iDroid,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-07-20 14:15:58

Jeśli chcesz go programowo zmienić:

yourText.setLinkTextColor(Color.RED);
 34
Author: Hamid,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-02-14 22:28:05

Musisz użyć android:textColorLink="#000000" gdzie 000000 jest kodem szesnastkowym twojego koloru. Mam nadzieję, że to pomoże.

 12
Author: Zwiebel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-01-11 00:27:23

Możesz użyć na swoim pliku XML:

android:textColorLink="Code" 

"kod" może być np. #ff0000 lub @color / red

Możesz użyć na swoim kodzie JAVA:

tv.setLinkTextColor(color);

Kolor może być np. Color.RED lub Color.parseColor("#ff0000");

 11
Author: Dario Bruzzese,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-23 07:35:23

Można również otworzyć kolory.xml i zmień następujący kolor na dowolny:

<color name="colorAccent">#FF4081</color>
 2
Author: Darush,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-03 20:53:01

Musisz użyć android:textColorLink="colorCode" . Mam nadzieję, że się uda.

 2
Author: user2314153,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-28 12:44:39

Jeśli ktoś musi znać wartość hex dla tego niebieskiego To jest #7bc9c2.

Użyłem kroplomierza, aby to rozgryźć, ponieważ nigdzie nie mogłem znaleźć tego udokumentowanego, i tak nie ma go w Google Color Palatte:

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

 1
Author: Lara Ruffle Coles,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-02-22 11:30:48

W pliku xml znacznika Textview

Android: autoLink= " web " / / podlinkuj zawartość www
android: textColorLink=" # FFFFFF " / / Zmień kolor linku

 0
Author: Makvin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-07-05 05:25:08