如何设置绘制文本的文本填充?

时间:2011-03-24 08:56:27

标签: android layout

我有自定义的edittext,其中包含以下行和亚麻布:

enter image description here

如何从绘制的文本中直接放置普通文本?

upd:代码:

 public LinedEditText(Context context, AttributeSet attrs) {
                super(context, attrs);

                mRect = new Rect();
                mPaint = new Paint();
                mPaint.setStyle(Paint.Style.STROKE);
                mPaint.setColor(Color.rgb(198, 198, 198));

                mTextPaint = new Paint();
                mTextPaint.setStyle(Paint.Style.STROKE);
                mTextPaint.setAntiAlias(true);
                mTextPaint.setColor(Color.rgb(234, 188, 96));

            }

            @Override
            protected void onDraw(Canvas canvas) {
                int count = getLineCount();
                Rect r = mRect;
                Paint paint = mPaint;
                mTextPaint.setTextSize(this.getTextSize());
                Paint PaintText = mTextPaint;

                for (int i = 0; i < count; i++) {
                    int baseline = getLineBounds(i, r);
                    canvas.drawText(Integer.toString(i), r.left, baseline + 1, PaintText);
                    canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);   
                }
                super.onDraw(canvas);
            }

1 个答案:

答案 0 :(得分:0)

在输入文本

时设置填充