D
Deleted member 103
Guest
Hi,
can someone help me?
I have found this code and want to use either with directly B4a or convert it to a library.
can someone help me?
I have found this code and want to use either with directly B4a or convert it to a library.
B4X:
Public 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.FILL_AND_STROKE);
mPaint.setColor(R.color.edit_note_line); //SET YOUR OWN COLOR HERE
}
@Override
protected void onDraw(Canvas canvas) {
//int count = getLineCount();
int height = getHeight();
int line_height = getLineHeight();
int count = height / line_height;
If (getLineCount() > count)
count = getLineCount();//For long text with scrolling
Rect r = mRect;
Paint paint = mPaint;
int baseline = getLineBounds(0, r);//first line
For (int i = 0; i < count; i++) {
canvas.drawLine(r.left, baseline + 1, r.right, baseline + 1, paint);
baseline += getLineHeight();//Next line
}
super.onDraw(canvas);
}
}