11

When you do, for example,

Linkify.addLinks(mTextView, Linkify.EMAIL_ADDRESSES);

what colour does Linkify use? It's not obviously in android.graphics.Color.

I have a few long paragraphs of stuff I just want standard links in, and one I need to do stuff with myself that I'd like to look the same, but I can't work out what colour to set it to. I could just recolour all the others, but that seems a very long way around.

Ben Williams
  • 5,838
  • 2
  • 28
  • 48

3 Answers3

14

The default style uses #05c5cf, and the inverse style (I'm guessing this is for the light theme) uses #0000EE (at least in platform versions up to 2.2). No guarantees it stays that way, though, but I don't anticipate they'll change that (but who can really tell).

Femi
  • 62,839
  • 8
  • 114
  • 142
  • 1
    Neither of those match for me; it looks more like #5858F8. Are they overlaid on the original colour somehow (eg, using something like PorterDuff.Mode.MULTIPLY)? – Ben Williams May 06 '11 at 14:55
  • 1
    Ah: the dark theme color changed between versions: try `#5c5cff` for dark themes. Light themes are still `#0000ee`. – Femi May 06 '11 at 15:11
  • Yep, that's it, thank you -- which, yay!, but also that means it changes between versions, so I can't guarantee a match anyway. Rats! >:( – Ben Williams May 06 '11 at 15:17
  • 2
    Actually, what you want is `android.R.color.link_text_dark` and `android.R.color.link_text_light` and you should be able to match to version. – Femi May 06 '11 at 15:22
  • Those don't appear to exist for me. Eclipse says it can't find them. – Ben Williams May 06 '11 at 15:30
  • 3
    Odd. Those do appear to be platform-private. Try `android.R.attr.textColorLink` and see if that works: it's bound to the underlying theme so that SHOULD pick the right one. – Femi May 06 '11 at 16:11
  • getResources().getColor(android.R.attr.textColorLink) throws Resources$NotFoundException with message Resource ID #0x101009b. – Ben Williams May 06 '11 at 16:19
  • Really odd: what Android revision are you building against? `getResources().getColor(android.R.attr.textColorLink);` and `devicelist.setTextColor(android.R.attr.textColorLink);` work fine for me when building against Android 2.0, and as far as I can tell the same attribute exists in Android 2.3.3. – Femi May 06 '11 at 16:39
11
Textview.getLinkTextColors().getDefaultColor()
Taryn
  • 224,125
  • 52
  • 341
  • 389
boiledwater
  • 9,994
  • 4
  • 34
  • 37
5

By default, the links use android:textColorLink defined in the theme.

rds
  • 24,304
  • 16
  • 97
  • 124