Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText Blinking Cursor

I have only one EditText in my Activity and I want it to hide the blinking cursor once the input is done - either the focus is switched or user presses Done - in other words, as the input keyboard disappears.
Here's the code for the EditText.

<EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="-4dp"
                android:id="@+id/editText"
                android:textColor="@color/theme2"
                android:textSize="15dp"
                android:singleLine="true"
                android:maxLines="1"
                android:background="@android:color/transparent"
                android:imeOptions="actionDone"
                android:nextFocusUp="@id/editText"
                android:nextFocusLeft="@id/editText"/>
like image 778
ai. Avatar asked Nov 10 '14 19:11

ai.


People also ask

How to stop the Blinking cursor in Android studio?

How do I change my blinking cursor to normal? You are correct, just hit the insert key on your keyboard and the flashing will immediately stop.

How do you hide the cursor in an EditText field when the keyboard is dismissed?

How do I remove the cursor from Edit text? You can use either the xml attribute android:cursorVisible="false" or programatically: java: view. setCursorVisible(false)Below also opens keyboard when EditText is clicked, and hides it when you press done in the keyboard.

How to hide cursor in EditText Android?

“setCursorVisible(false)” This method hides the cursor in the Edit Text when the application launches.


2 Answers

To stop the cursor from blinking in an EditText, simply use this line:

editText.setCursorVisible(false);

That's it.

like image 91
Alessandro Roaro Avatar answered Sep 30 '22 19:09

Alessandro Roaro


I would simply

editText.clearFocus();
like image 31
Aleksandarf Avatar answered Sep 30 '22 19:09

Aleksandarf