android - Line edittext have space from top -
i want create line edittext , set it's height match parent when display have space top shown in below image.
here code :
public class lineedittext extends edittext { private rect mrect; private paint mpaint; public lineedittext(context context, attributeset attrs) { super(context, attrs); mrect = new rect(); mpaint = new paint(); mpaint.setstyle(paint.style.fill_and_stroke); mpaint.setcolor(color.parsecolor("#afaaaa")); } @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); (int = 0; < count; i++) { canvas.drawline(r.left, baseline + 1, r.right, baseline + 1, paint); baseline += getlineheight(); } super.ondraw(canvas); }
edittext.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <app.lichconggiao.custom.lineedittext android:id="@+id/edtnote" android:textsize="20dp" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margintop="10dp" android:ems="10" android:textcolor="#212121" /> </linearlayout>
and screen display
how can fix it? please me thank alot
Comments
Post a Comment