draw line under TextView on Android

后端 未结 4 1709
野性不改
野性不改 2021-02-07 00:05

I have a layout that adds textviews dynamically and i want to divide each textview with a line.

Something like that:

TextView


TextView


<
4条回答
  •  走了就别回头了
    2021-02-07 00:56

    If you want to add programmatically then do this:

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

    or you can add this to strings.xml:

    This is an underline.
    

    or :

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

提交回复
热议问题