Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard issues arising on orientation change

In my app I am using various edit text and text view and list view. Now my problem is my keyboard appears again on orientation change. Ideally when user minimize the keyboard, it should be in minimized state when device is tilted. But it reappears. How do we handle this situation.

My other problem is one of my edit text is some what at the end of screen. When keyboard appears, it hides the edit text. so user is not able to see what he is typing. What is the ideal way to handle this. thanks.

like image 536
Android Avatar asked Oct 03 '12 09:10

Android


2 Answers

Solution to all problem is this line android:windowSoftInputMode="stateUnchanged|adjustResize"

"stateUnchanged" will make the state of keyboard same as it was in earlier state. Either hidden or visible.

"adjustResize" will make your edit text visible.

Hope this helps.!!!

Edit

This need to be added in android manifest file.

like image 156
Android Avatar answered Sep 21 '22 05:09

Android


I had this same problem. To keep the keyboard from re-appearing on rotation when you have TextViews, you must do 2 things-

  1. Make sure the TextView doesn't have the focus. Even after hiding the keyboard, a TextView can still be focused. Try calling

    textView.clearFocus()
    

    and you should be able to see the difference in the TextView.

  2. Make sure there is another view before it (like a parent LinearLayout, or even just a LinearLayout with 0 width and 0 height) which has these properties-

    android:focusable="true"
    android:focusableInTouchMode="true"
    
like image 27
Patrick Avatar answered Sep 20 '22 05:09

Patrick