Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App Building the Weather UI The Legal Side of APIs

How to remove underline for Powered by Dark Sky TextView?

I figured that textColorLink will change the color of the TextView caused by assigning a link but cannot figure out how to remove the underline that indicates the text has an anchor. Stackoverflows tells some ways but I don't know why it has to be such complicated for the seemingly easy task of writing a few tags to set the style.

3 Answers

Hi. May I ask why you would want to remove the underline? It is here to signal the user that there's a hyperlink attached to the text and clicking on it takes them to the website.

If you do not want to go with that, just remove the hyperlink from the string resource, make your Powered by Dark Sky TextView clickable and create an intent that opens up the given webpage into a browser.

Hope that helps :)

That's a good alternative to the question although I would know that if I wasn't looking for seemingly quick trick to do that like text-decoration=none in CSS.

I see. Thanks for explaining. I'm not aware of anything similar in Android, no. Intents are usually used. But maybe someone else here does know a quick hack.

Ryan Dsouza
Ryan Dsouza
9,388 Points

It's really complex. I would use a simple markup in XML by using the style attribute. Not the best practice but for such a small request, using an entire method in main activity seems an overkill

But the notion of ensuring that the user know's its a link by seeking the underline is super valid.

Hi Ryan Dsouza. Would you mind sharing your xml-only solution here please? It would benefit everyone. Thank you :)

Ryan Dsouza
Ryan Dsouza
9,388 Points

Hi Lauren Moineau,

I was wrong about that approach. I assumed that android would give me privileges as I had for the normal XML file. I believe right now, that the only way to implement this request is using the following approach mentioned in this Link

Hi Ryan. Thank you for sharing. The tutorial you linked will remove the underline indeed but I'm afraid it would not work with this project as the android:autoLink="web" XML attribute and the URLSpan class only apply to a text containing a URL. It is not the case in this project as the text for the credits is "Powered by DarkSky". We could, of course, decide to write "Powered by www.darksky.net", in which case the solution you shared will be fine.

Another way to remove the underline for this project (on a text without URL) would be to use Linkify with a custom link String, using a RegEx pattern, but it definitely feels like a lot of work for such a small piece of text. I still believe a simple 3-line intent with a clickable textview would be quite a sensible solution in this case.

Ryan Dsouza
Ryan Dsouza
9,388 Points

Lauren Moineau Your solution makes a lot of sense. I was too obsessed with doing that modification in XML that I didn't think elsewhere.