5

I'm having a small user experience issue in my app;

When changing from landscape to portrait (or portrait to landscape) with the Soft Keyboard open, the keyboard hides.

What I want to do is to stop the keyboard hiding on orientation change.

(Edit - I don't want to force the keyboard open, if the keyboard was hidden before the orientation change, I want it to stay hidden - I want to retain the keyboards open/closed state).

I've looked around for an answer and it seems adding stateUnchanged to the windowSoftInputMode options in the manifest for the Activity is the correct way to solve this (as described in the android documentation:

android:windowSoftInputMode="stateUnchanged|adjustResize" 

The problem is this seems to have absolutely no effect.

Does anybody know of any caveats to this functionality? Does it perhaps not work if the EditText which is focused is in a Fragment?

Graeme
  • 25,714
  • 24
  • 124
  • 186

1 Answers1

0

Add this to your code and it will work :

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Harish Godara
  • 2,388
  • 1
  • 14
  • 28
  • 2
    This forces the keyboard to be visible - What I want to do is retain the keyboard state across orientation change. – Graeme Aug 12 '13 at 08:49
  • @Graeme you probably can not. It is up to the keyboard implementation whether or not it wants to retain the previous state after a configuration change. – AL-zami May 29 '23 at 13:12