Android-edittext-underline

Android-edittext-underline,android,line,android-edittext,underline,Android,Line,Android Edittext,Underline,有没有办法使多行编辑文本中的所有行都加下划线? 我希望所有的行都显示该行,即使上面没有文本。这种事情在示例演示中完成。如果我们查看,我们可以看到他们使用自定义文本编辑器,如下所示: /** * A custom EditText that draws lines between each line of text that is displayed. */ public static class LinedEditText extends EditText { private Rec

有没有办法使多行编辑文本中的所有行都加下划线?
我希望所有的行都显示该行,即使上面没有文本。

这种事情在示例演示中完成。如果我们查看,我们可以看到他们使用自定义文本编辑器,如下所示:

/**
 * A custom EditText that draws lines between each line of text that is displayed.
 */
public static class LinedEditText extends EditText {
    private Rect mRect;
    private Paint mPaint;

    // we need this constructor for LayoutInflater
    public LinedEditText(Context context, AttributeSet attrs) {
        super(context, attrs);

        mRect = new Rect();
        mPaint = new Paint();
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(0x800000FF);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        int count = getLineCount();
        Rect r = mRect;
        Paint paint = mPaint;

        for (int i = 0; i < count; i++) {
            int baseline = getLineBounds(i, r);

            canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
        }

        super.onDraw(canvas);
    }
}
/**
*自定义编辑文本,在显示的每行文本之间绘制线条。
*/
公共静态类LinedEditText扩展了EditText{
私人直肠;
私人油漆;
//我们需要这个构造器来实现LayoutFlater
public LinedEditText(上下文、属性集属性){
超级(上下文,attrs);
mRect=新的Rect();
mPaint=新油漆();
mPaint.setStyle(油漆、样式、笔划);
mPaint.setColor(0x800000FF);
}
@凌驾
受保护的void onDraw(画布){
int count=getLineCount();
Rect r=mRect;
油漆油漆=mPaint;
for(int i=0;i
然后,他们在以下文件中声明:



如何在该视图上写入文本?看起来不错!谢谢
<view xmlns:android="http://schemas.android.com/apk/res/android"
    class="com.example.android.notepad.NoteEditor$LinedEditText"
    android:id="@+id/note"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent"
    android:padding="5dp"
    android:scrollbars="vertical"
    android:fadingEdge="vertical"
    android:gravity="top"
    android:textSize="22sp"
    android:capitalize="sentences" />