Is there a way to make an application completely ignore a screen orientation change?
On the main screen of Rotation Manager, select an orientation by tapping on either the vertical or horizontal icons next to a specific app to lock it into either landscape or portrait mode. Highlighting both icons will allow that particular app to auto-rotate.
Android Settings Start by going to Settings => Display and locate the “Device rotation” setting. On my personal cell phone, tapping this will reveal two options: “Rotate the contents of the screen,” and “Stay in portrait view.”
In Android Studio 1 one simple way is to add android:screenOrientation="nosensor" . This effectively locks the screen orientation.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With