android - EditText custom cursor incorrectly drawn in first row -
i have edittext in main layout. have app theme, default edittext styled custom curdordrawable.
<edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/introedittext" android:gravity="top" android:singleline="false" android:text="" android:inputtype="textmultiline" android:textsize="24sp" > <requestfocus/> </edittext> <style name="apptheme" parent="android:theme.holo.noactionbar"> <item name="android:textcolor">#ffffff</item> ... <item name="android:edittextstyle">@style/edittextstyle</item> </style> <style name="edittextstyle" parent="@android:style/widget.edittext"> <item name="android:background">@android:color/transparent</item> <item name="android:textcursordrawable">@drawable/cursor</item> </style>
and custom cursor is:
<shape xmlns:android="http://schemas.android.com/apk/res/android" > <size android:width="2dp" /> <solid android:color="#363636" /> </shape>
the cursor color correct, although width isn't. on first row it's 1 px wide instead of 2dp. text breaks 2 lines, cursor becomes 2dp wide. also, not shown when edittext has no text. tested on 4.4 (htc 1 , nexus 7) android bug?
actually width of edittext increases, cursor's size set masked space(can't figure out was). solution fix edittext width.
<edittext android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/introedittext" android:gravity="top" android:singleline="false" android:text="" android:inputtype="textmultiline" android:textsize="24" />
if want exact width, use ems like:
<edittext android:ems="10" ... />
android:ems sets width of textview fit text of n 'm' letters when text size 12sp
i don't think there's way around this.
Comments
Post a Comment