开发者

How to set padding of text from drawn text?

I have custom edittext with lines and linenumbering like this:

How to set padding of text from drawn text?

How can I place normal text right from the drawn text?

开发者_JAVA技巧

upd: Code:

 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);
            }


set the padding at that time of enter the text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜