Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing Cursor inside EditText when focus is not on EditText

Tags:

Image of a grid-like layout

I am working on Android Smart TV application:

  • In a view there is a custom keyboard and an EditText.

  • When application launches focus goes to the keyboard.

    Desired:

    • When the user types with keyboard (clicking with a remote) the cursor should also blink inside the editText.

How can I show this effect inside the EditText?

like image 240
nitin tyagi Avatar asked May 20 '15 09:05

nitin tyagi


People also ask

How do I change the cursor position in EditText?

Say in your xml's edittext section, add android:paddingLeft="100dp" This will move your start position of cursor 100dp right from left end. Same way, you can use android:paddingRight="100dp" This will move your end position of cursor 100dp left from right end.

How do I hide the cursor on my android?

To hide the cursor we implement this method for each Edit Text: “setCursorVisible(false)”


1 Answers

This happens if you set a background for the field. If you want to solve this, set the cursorDrawable to @null.

You should add textCursorDrawable with cursorVisible.

Reference to a drawable that will be drawn under the insertion cursor.

android:cursorVisible="true" android:textCursorDrawable="@null" 
like image 82
IntelliJ Amiya Avatar answered Sep 18 '22 17:09

IntelliJ Amiya