EditText
Android development
cursor
user interface
mobile app development

Disable EditText blinking cursor

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

If you want an EditText without the blinking cursor, the simplest fix is to hide the cursor itself rather than trying to disable the whole control. On Android, that usually means setting cursorVisible to false, either in XML or in code.

The XML Approach

For a static layout, this is enough:

xml
1<EditText
2    android:id="@+id/nameInput"
3    android:layout_width="match_parent"
4    android:layout_height="wrap_content"
5    android:cursorVisible="false" />

This keeps the field editable but removes the visible blinking caret.

The Programmatic Approach

In Kotlin:

kotlin
val editText = findViewById<EditText>(R.id.nameInput)
editText.isCursorVisible = false

In Java:

java
EditText editText = findViewById(R.id.nameInput);
editText.setCursorVisible(false);

This is useful when the behavior depends on runtime state.

XML Versus Code

Use XML when the field should never show a blinking cursor in that layout. Use code when the behavior depends on mode, such as editable in one screen state and display-only in another. The underlying setting is the same, but choosing the right place to apply it keeps the intent clearer.

Know What This Does Not Change

Hiding the cursor does not automatically make the field read-only. The user can still focus the field and edit text unless you also change:

  • Focusability
  • Input handling
  • Key listener behavior

So if the true goal is a non-editable field that merely looks like text, hiding the cursor is not the full solution.

If You Also Want It Non-Editable

For a display-only field:

kotlin
editText.isCursorVisible = false
editText.isFocusable = false
editText.isFocusableInTouchMode = false

Or consider using TextView instead of EditText if editing is never intended.

That is usually the cleaner UI choice. If the user should not type there, TextView communicates intent better than a visually disabled EditText.

Custom Cursor Drawable Versus Visibility

Some developers try to make the cursor transparent by changing the cursor drawable. That can work, but it is usually more complicated than necessary when the only goal is "no blinking cursor." cursorVisible="false" is the clearer choice unless you still want a custom visible cursor style.

User Experience Considerations

Removing the cursor can make focus less obvious. If the field remains editable, users may not immediately realize where typing will go. If you hide the cursor, make sure the rest of the UI still communicates focus clearly through background color, outline, label state, or another visible cue.

This matters especially in forms, where the blinking caret is part of the normal "ready for input" signal. Removing it without a replacement can make the field feel broken even when it is technically functioning.

When a Non-Blinking Cursor Is Not Enough

Sometimes the real requirement is not "hide the blink" but "do not show any editing affordance at all." In that case, simply hiding the cursor is incomplete. You may also need to suppress keyboard entry, text selection, and focus so the field behaves like display text rather than like an input.

Common Pitfalls

  • Hiding the cursor and assuming the field is no longer editable.
  • Using EditText when TextView would better express the intended behavior.
  • Overcomplicating the fix with drawable hacks when cursorVisible is enough.
  • Removing the cursor without offering another focus indicator.

Summary

  • Use android:cursorVisible="false" or setCursorVisible(false) to disable the blinking cursor.
  • This hides the caret but does not make the field read-only.
  • If editing is not needed, also disable focus or use TextView instead.
  • Prefer the simple visibility flag over cursor-drawable tricks when possible.
  • Good UX still requires some visible focus feedback if the field stays editable.

Course illustration
Course illustration

All Rights Reserved.