在Editext的佈局屬性上加上 android:textCursorDrawable="@drawable/cursor_shape" cursor_shape如下: 事實證明:設置android:height無效,應該用padding的方法。 top設置為-2dp :讓游標頂部下移2dp bot ...
在Editext的佈局屬性上加上
android:textCursorDrawable="@drawable/cursor_shape"
cursor_shape如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size
android:width="1dp" />
<solid android:color="@color/comics_theme_color" />
<padding
android:top="-2dp"
android:bottom="-2dp"/>
</shape>
事實證明:設置android:height無效,應該用padding的方法。
top設置為-2dp :讓游標頂部下移2dp
bottom設置為-2dp:讓游標底部上移2dp
這樣子游標的高度就變小了4dp
從下麵的源碼可以大概看出原因:
private void updateCursorPosition(int cursorIndex, int top, int bottom, float horizontal) { ... mCursorDrawable[cursorIndex].getPadding(mTempRect); ... mCursorDrawable[cursorIndex].setBounds(left, top - mTempRect.top, left + width, bottom + mTempRect.bottom); }