I am developing Android Application like Note App. All of things were going pretty well.Here my output.
But, I have facing a problem that is the lines in my EditText become unequal with text when I typed Myanmar Language (one of South East Asia Language), here my output,
I googled and try many ways. But, it can't help me. Below are my code. Kindly!
LinedEditText.java
public class LinedEditText extends android.support.v7.widget.AppCompatEditText {
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 height = getHeight();
int line_height = getLineHeight();
int count = height / line_height;
if (getLineCount() > count)
count = getLineCount();
Rect r = mRect;
Paint paint = mPaint;
int baseline = getLineBounds(0, r);
for (int i = 0; i < count; i++) {
canvas.drawLine(r.left, baseline + 2, r.right, baseline + 2, paint);
baseline += getLineHeight();
}
super.onDraw(canvas);
}
}
actvity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:maxLength="10"
android:ems="10"
android:hint="Title Here" />
<login.fb.ucsy.com.notepad.LinedEditText
android:id="@+id/edit_story"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@null"
android:inputType="textMultiLine|textNoSuggestions"
android:minLines="10"
android:gravity="top|left"
android:singleLine="false"
android:imeOptions="actionNone"
android:text="Story : \n" />
</LinearLayout>