2

I am now showing the keyboard once tapping on a EditText field with the activity attribute android:windowSoftInputMode="adjustNothing" in AndroidManifest.xml so as to disable view scroll up animation. Now I hide the keyboard using the following:

editText.clearFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

But this would produce a scroll up animation first before hiding the keyboard. I would like to know how to hide keyboard without this animation.

P.S. This happens on my Android 5.1.1 Samsung Galaxy J1(2016) device.

I change to android:windowSoftInputMode="stateVisible|adjustPan" for the activity and the animation still appears.

Updates:

I found that the animation is caused by editText.clearFocus();. If I remove this line, there would be no animation, but the cursor is still blinking, which is not I want.

I now used a workaround to show / hide the cursor blinking in this SO post without clear the focus of the EditText.

Community
  • 1
  • 1
chubao
  • 5,871
  • 6
  • 39
  • 64

0 Answers0