EditText cursor becomes invisible in JellyBean
Asked Answered
W

5

14

In my app, I have an edit text with properties:

android:inputType="none" and android:textIsSelectable="true".

It's because I have defined my own buttons to enter input (buttons, not custom keyboard). I have used

editText.requestFocus()

to make the cursor visible. Upto to android 4.0.4, the cursor is visible and not in phones running Jelly Bean. The cursor isn't visible but I'm able touch and enter text between characters ( using editText.getSelectionStart() ).

What has changed in Jelly Bean? How do I make the cursor visible?

Edit: android:cursorVisible="true" isn't helping.

Willtrude answered 20/8, 2013 at 15:50 Comment(0)
W
38

Removing android:textIsSelectable="true (text is selectable even without this)

and adding

android:textCursorDrawable="@null" fixed the issue.

Willtrude answered 24/8, 2013 at 6:25 Comment(1)
The cursor could be invisible because it blends with the background colour. The null above forces it to use the android:textColorCarollcarolle
M
11

In Jellybeans, it happens if you set background to editText.

To show cursor in editText, just use android:textCursorDrawable="@null" and android:textColor="@color/someColor"

Mcgary answered 25/8, 2013 at 14:57 Comment(0)
U
0

Try adding the following:

android:clickable="false"
Unmeriting answered 20/8, 2013 at 16:3 Comment(1)
I need to be able to set cursor. Won't this prevent that?Willtrude
A
0

Setting android:textCursorDrawable="@android:drawable/my_cursor_drawabl" as shown below.

Theme's editText style :

<item name="android:editTextStyle">@style/myEditText</item>

Following drawable to set the cursor:for android:textCursorDrawable property of edit-text

<style name="myEditText" parent="@android:style/Widget.Holo.Light.EditText">
    <item name="android:background">@android:drawable/editbox_background_normal</item>
    <item name="android:textCursorDrawable">@android:drawable/my_cursor_drawable</item>
    <item name="android:height">45sp</item>
</style>

check this

Anthropomorphous answered 24/8, 2013 at 5:49 Comment(1)
I have added the <style> to styles.xml. Where must I add the <item>? And what must be in drawable/color_cursor.xml?Willtrude
S
0

Remove the background attribute from the parent. e.g android:background="#FFFFFF"

Sarisarid answered 21/2, 2015 at 20:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.