Scorpio
Scorpio

Reputation: 1144

EditText cursor not visible

I have an EditText and the cursor is invisible. What can I do to show it? This is the EditText in XML:

<RelativeLayout
        android:id="@+id/text_field"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="7dp"
        android:background="@drawable/box_message" >
    <myApp.EditTextView
        android:id="@+id/text_editor"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignWithParentIfMissing="true"
        android:layout_centerVertical="true"
        android:cursorVisible="true"
        android:textCursorDrawable="@null"
        android:layout_toLeftOf="@+id/send_side"
        android:hint="@string/Enter_message_Hint"
        android:imeOptions="actionSend|flagNoEnterAction"
        android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
        android:maxLength="1000"
        android:maxLines="3"
        android:nextFocusRight="@+id/send_button"
        android:padding="12dp"
        android:textSize="13sp"/>
</RelativeLayout>

It is a custom EditText that has all 3 constructors.

public EditTextView(Context 
{
this(context, null);
}

public EditTextView(Context context, AttributeSet attributeset)
{
this(context, attributeset, 0);
}

public EditTextView(Context context, AttributeSet attributeset, int defStyle)
{
super(context, attributeset, defStyle);

//set onTouch listener.
}

I already tried without android:textCursorDrawable="@null" and it didn't work.

Upvotes: 0

Views: 1833

Answers (4)

support_ms
support_ms

Reputation: 1933

Set some value to minWidth in xml 1,2,3.. Ex:minWidth="1px" to your EditText's xml

<myApp.EditTextView
minWidth="1px"
.
.
./>

Upvotes: 0

Ajinkya S
Ajinkya S

Reputation: 570

May be because of your background color the cursor is not visible, try to make the gravity center due to which the cursor will be visible.

android:gravity="center"

Upvotes: 1

erakitin
erakitin

Reputation: 11517

The cursor is displayed when EditText's state is "focused". Make sure that the EditText is focusable. Try to add following attributes: android:focusable="true" android:focusableInTouchMode="true". But I think that the problem can be in code of your custom EditText.

Upvotes: 0

schubakah
schubakah

Reputation: 435

The code you posted seems correct, so the Problem lies somewhere beyond this scope. I had this problem once and it was due to the wrong context with which I called the constructor. You can check if you actually call the Constructor with the right Application Context. I am afraid, though, that the Problem probably lies somewhere else.

Upvotes: 0

Related Questions