<string-array name="myarray">
<item>Apple</item>
<item>Banana</item>
<item>Grape</item>
<item>Melon</item>
if i want to add Underline the "Banana" what should I add?
You can also underline a portion of the text via code, it can be done by creating a SpannableString and then setting it as the TextView text property: SpannableString text = new SpannableString("Voglio sottolineare solo questa parola");text. setSpan(new UnderlineSpan(), 25, 6, 0);textView. setText(text);
One line solution. myTextView. setText(Html. fromHtml("<p><u>I am Underlined text</u></p>"));
Text styling is one of the important aspects when it comes to enhancing the UI of an Android application. In Android, we can change the size, color, weight, style, etc of a text and make the text more attractive and appealing.
use SpannableString
by which you can do Underline, Strike, Highlight, Bold, Italic etc to the text
for Underline you have to use UnderlineSpan
http://developer.android.com/reference/android/text/style/UnderlineSpan.html
TextView textview = (TextView)findViewById(R.id.textview);
SpannableString content = new SpannableString("Apple Banana Grape Melon");
content.setSpan(new UnderlineSpan(), 6, 11, 0);
textview.setText(content);
or simply by adding HTML tag to the resource string <string name="sample"> <u>your data</u></string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With