android 自定义View 线型EditText输入框

public class LineEditText extends AppCompatEditText {
    private Paint mPaint;

    /**
     * @param context
     * @param attrs
     */
    public LineEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
        mPaint = new Paint();

        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(context.getResources().getColor(R.color.white));
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);

//      画底线
        canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, mPaint);
    }
}

猜你喜欢

转载自blog.csdn.net/zww986736788/article/details/88552789