It is possible, quite easily, to override the default behavior and forbid a screen orientation change when the keyboard is open/closed.
Modifying the manifest
Open the manifest, switch to the Application tab and select the desired Activity you wish to override for the orientation change behavior.
-
Within Attributes you need to change two fields:
Screen orientation: select either portrait or landscape – whichever is desired. This will be the default layout. -
Select events for Config changes you wish to override:
In this case these are keyboardHidden and orientation.
Modifying the Activity implementation
Now you need to override a single function within desired Activity.
Just add the function below to your Activity’s class.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
This is the default implementation if using the Source->Override/Implement Methods
menu option.
That’s it! Now your orientation will always be kept.
Remember that this setting is per Activity – so you need to repeat this step for each Activity you wish to forbid the orientation change!
(Based on SDK 1.1)