If your app need an underline for the text in TextView
Achieve it in simple way - (By both xml and code part)
xml
It can be achieved if you are using a string resource xml file, which supports HTML tags like <b></b>, <i></i> and <u></u>
Code
Way - 1
Achieve it in simple way - (By both xml and code part)
xml
It can be achieved if you are using a string resource xml file, which supports HTML tags like <b></b>, <i></i> and <u></u>
<resources>
<string name="your_string_here">This is an <u>underline</u>.</string>
</resources>
Code
Way - 1
TextView textView = (TextView) view.findViewById(R.id.textview);
SpannableString content = new SpannableString("Hello, Android !!!");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
textView.setText(content);
Way - 2textview.setPaintFlags(textview.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);Way - 3
textview.setText(Html.fromHtml("<u>Text to underline</u>"));
Comments
Post a Comment