I'm trying to programmatically set the screen orientation to reverse portrait.
The request to change the screen orientation only works for orientations other than reverse portrait.
setOrientation
and the use of a system dialog to change the orientation. The problem occurs regardless of which method is used. I'm developing with a Sony Xperia M (Android 4.1.2).
You can set it in xml in the manifest file using :
android:screenOrientation="reversePortrait"
The similar effect programmatically:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
Another approach could be to set the rotation of the root layout to 180 degrees. How ever it doesnot rotate the actionbar.
android:rotation="180"
You should use android:screenOrientation="fullSensor"
to enable orientation in all 4 orientations, as explained here
EDIT:
Turning 'auto-rotate' off forces the orientation to 'portrait' mode. I am unaware of any way around this without using the manifest.
If auto-rotate is on then initializing the app in 'fullsensor' mode and then changing to 'reverse portrait' based on configuration changes or screen orientation changes will rotate your app to that mode.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.