I've written an app which contains a large textview for displaying notes. Is it possible to have the textview highlight any phone numbers or hyperlinks without underlining the entire view?
Asked
Active
Viewed 1.9k times
2 Answers
61
<TextView
...
android:autoLink="all"
/>
That's actually enough for you

Fedor
- 43,261
- 10
- 79
- 89
-
Yeah, I keep forgetting about this. `Linkify` is good if you need more control, or only want to apply a conversion to part of the text. – CommonsWare Jun 14 '10 at 20:25
-
Thanks. I got what I was searching for. – Kiran Kulkarni Oct 19 '11 at 01:42
-
I'm prompted to add the number to my contacts rather than dialing. I'm using an Android 4.3 Emulator. Is that the expected behavior vs. opening the dialer? – Bill Mote Nov 08 '13 at 14:12
-
@BillMote late reply, but maybe someone would need it. It happens, because emulator doesn't have dealer app. – rstk Sep 25 '15 at 02:02
-
Is there a way to control the color of the links? – Justin Nov 03 '16 at 16:03
-
1Never mind, I found it... android:textColorLink="yourcolorhere" – Justin Nov 03 '16 at 16:06
11
You can use Linkify
to turn phone numbers, URLs, and such into links that, when clicked on, launch appropriate apps (Dialer, Browser, etc.).
If you were fishing for just an underline effect, without the links, you can:
- Mark up your text with HTML, particularly
<u>...</u>
for underlines - Run that through
Html.fromHtml()
to get aSpannable
with your formatting in place - Feed that
Spannable
to yourTextView
viasetText()
Here is the list of HTML tags supported by Android 2.1's edition of Html.fromHtml()
. Note that this is not officially documented anywhere, so your mileage may vary.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491