Skip to content Skip to sidebar Skip to footer

Unresponsive Soft Keyboard For A Couple Of Seconds In Edittext When I Move The Cursor In The Widget

When I move the cursor in a EditText widget the soft keyboard is unresponsive for a couple of seconds. I have cold booted the device, and tried a different keyboard but the problem

Solution 1:

I got the same problem as you. As you said, it just happens on Samsung device.

I set some texts in the Editview in the onCreate and the cursor initially appears at the start of the text when the layout is shown. Then if we move the cursor to the end of the text and type back button immediately, the keyboard will lose response for several seconds. While it is working if you type another button rather than back button.

The possible affected case is users want to delete the existing text, so they type the back button. This issue makes them feel they have to type the back button multiple times to start deleting the text.

The possible solution is setting the cursor at the end of the text when initializing the EditView, something like:

 mUsernameEditView.setSelection(username.length());

I understand it is not perfect, but have other ideas.

Update

The real reason is I override android:textSelectHandle, android:textSelectHandleLeft and android:textSelectHandleRight in the AppTheme like below:

<stylename="AppTheme"parent="Theme.AppCompat.Light.DarkActionBar"><itemname="android:textSelectHandle">@android:color/black</item><itemname="android:textSelectHandleLeft">@android:color/black</item><itemname="android:textSelectHandleRight">@android:color/black</item></style>

The issue is gone after commenting on the code above, but how to change the selection color?

Solution 2:

As @Freddie pointed out, the issue with delayed keyboard taps seems to only occur on Samsung devices if we set any of the following attributes in the Theme or EditText level.

<stylename="AppTheme"parent="Theme.AppCompat.Light.DarkActionBar"><itemname="android:textSelectHandle">@android:color/black</item><itemname="android:textSelectHandleLeft">@android:color/black</item><itemname="android:textSelectHandleRight">@android:color/black</item></style>

However, there is another way we can set the handle colors. We can do this by setting the colorControlActivated attribute instead. From the Android docs, this attribute is:

The color applied to framework controls in their activated (ex. checked) state.

May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

It turns out that these textSelectHandle* attributes fall into this category.

Note we can only set colorControlActivated at the Theme level for it to take effect; setting this attribute in your EditText will not change anything:

<stylename="AppTheme.YourHandleColorHere"><itemname="colorControlActivated">@color/your_handle_color_here</item></style>

If you only want this for specific EditTexts, you can set your EditText's theme to:

<EditTextandroid:theme="@style/AppTheme.YourHandleColorHere"/>

Post a Comment for "Unresponsive Soft Keyboard For A Couple Of Seconds In Edittext When I Move The Cursor In The Widget"