Android TextView link without underline? - android

I use a TextView with links by this:
TextView tv ...
tv.setText( Html.fromHtml(somehtml))
It is ok to control the link color by setting attribute android:textColorLink, but can I remove the underline of it?

OK now with html anchor tag, to avoid the underline now use the property STYLE="text-decoration:none"
< a STYLE="text-decoration:none" HREF=\"link.html\">it has no underline < /a >
this must work with a WebView but in a TextView I was using Android 1.5, 1.6 and thats not possible. =(

Just remove the html < u > tag, that indicates an underline text !

Spanned android.text.Html.fromHtml(String source, ImageGetter imageGetter, TagHandler tagHandler)
The important part is the TagHandler. You have to implement one and then you can hopefully modify it.
Another solution:
handle textview link click in my android app

Related

Highlight-style effect with multiline text in Android

What I would like to achieve is an effect that looks like this with a TextView:
Basically having a background, but keeping the space between the lines. The only solution I came up with was using one TextView for each line of text, but I would prefer a cleaner one using only one multiline TextView.
Any ideas?
Use spanned text for each line. Read the Spannable API.
please refer to this answer here as it describes how to implement spacing between multiple lines in a TextView , using the following properties :
android:lineSpacingMultiplier
android:lineSpacingExtra
Hope that Helps .
Regards
What you can do is use mark tag in html to textview.
myTextView.setText(Html.fromHtml("<mark>heading highlighted</mark>"));

Android textview different style for bold text

I have a long string, with multiple bold words inside the string.
The styling of the non bold sentences are done inside the TextView XML part and this is looking fine.
But i want to make the bold words bigger and thicker.
Is this possible to change this with XML?
for example:
<string name="long_text">This should be a <b>long</b> text with different <b>styling</b></string>
The bold words are supposed to be 1.5 times bigger
Or should i do this in the Java code?
yes you have to do this in java because there is no way to as per your requirement,
you can use TextAppearanceSpan in java code with Spannable
if i am getting you right than try the following..
textview.setText(Html.fromHtml(getResources().getString(R.string.long_text)));
Mark as right if it works for you .

Setting the text appearance of an android TextView in Java code

How can I set the text appearance of an android TextView to large in Java code? There is a method setTextAppearance(), but I don’t know how to use it.
Just try that:
textView.setTextAppearance(this, android.R.style.TextAppearance_Large);
Try this:
textView.setTextAppearance(android.R.style.TextAppearance_Large);

How set TextView text both clickable and selectable?

My textview load html text that contains links (to website, to e-mail address ...)
tv = (TextView)((Activity)mContext).findViewById(R.id.entry_webview);
tv.setText(Html.fromHtml(myPage));
I settv.setMovementMethod(LinkMovementMethod.getInstance()); to make the linke be clickable.
I set tv.setTextIsSelectable(true); to make the text selectable.
What happens? TextView applies just the last setting, in this order case, text will be ONLY selectable and the link(s) won't be clickable, one setting excludes the other other one.
If I set in TextView in XML
android:autoLink="all"
android:textIsSelectable="true"
links don't work (e-mail yes).
Is there a way to make the text both clickable and selectable?
Thanks.
I had the same issue - this solution works for me:
The XML TextView should not have any link/selectable attributes:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Then, set everything programmatically respecting the following order:
textView.setText(Html.fromHtml(myHtml));
Linkify.addLinks(textView, Linkify.WEB_URLS);
textView.setTextIsSelectable(true); // API-11 and above
textView.setMovementMethod(LinkMovementMethod.getInstance());
have you tried using something like this tv.setText(Html.fromHtml("<a href='url'>link</a>"));

Bold Style not applied to textview android

I'm using action bar with custom view for title to be able to add Title and Subtitle
I need to set Title Style to Bold, When I make it in the XML layout it works fine, but I need to set it from code using
textView.setTypeface(null, Typeface.BOLD);
but it does not work, can anyone please help
Ideally it should work. This may sound mundane but can you check if it gets reset somewhere after you set it to bold the first time in your Java file.
You can use this code to display HTML codes in textviews
textView.setText(Html.fromHtml("<b>BOLD WORDS HERE</b>"));

Categories

Resources