在Android 5.0(Lollipop)

时间:2015-05-21 12:57:57

标签: android android-edittext cursor

EditText光标在Android 4.0或更低版本上可见,但在Android 5.0(Lollipop)版本中未显示。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

在XML文件中添加android:cursorVisible="true"android:focusableInTouchMode="true"

示例:

<EditText 
    android:id="@+id/textLabel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:cursorVisible="true" 
    android:focusableInTouchMode="true"/>

有时EditText需要焦点来显示光标,所以它可能对你有所帮助。

答案 1 :(得分:1)

我已经解决了这个问题,就像这样link

问题是我这样使用它:

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:maxLength="50"
    android:textColor="#666666"
    android:textCursorDrawable="#666666"/>

如果你打算使用textCursorDrawable,你应该使用drawable res来表示这样的值:

android:textCursorDrawable="@drawable/red_cursor"
相关问题