[ACCEPTED]-draw line under TextView on Android-line

Accepted answer
Score: 64

This is the simplest and most similar to 7 using the <hr> tag in HTML:

Put this in your 6 XML layout where you want the line:

<View 
   android:layout_width="fill_parent"
   android:layout_height="1dp"       
   android:background="#ffffff" />

This 5 will draw a white line, 1 dp thick, across 4 the screen. If you want it to be a fixed 3 width, just change the layout_width to the dp size you 2 want. Change the background to the HTML color code 1 of your choice.

Score: 18

just add this style:

style="?android:listSeparatorTextViewStyle"

to your TextView

0

Score: 7

If you want to add programmatically then 2 do this:

mTextView.setPaintFlags(mTextView.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);

or you can add this to strings.xml:

<string name="your_string_here"><u>This is an underline</u>.</string>

or 1 :

SpannableString spannableStringObject= new SpannableString("Your text here");
spannableStringObject.setSpan(new UnderlineSpan(), 0, 
spannableStringObject.length(), 0);
textView.setText(spannableStringObject);
Score: 3

You can build a ListView, it has a divider, and 1 you can add line dynamically。

More Related questions