[英]Can't use reverse portrait orientation without “Auto-Rotate Screen” enabled
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. setOrientation
和使用系统对话框来更改方向。 The problem occurs regardless of which method is used. I'm developing with a Sony Xperia M (Android 4.1.2). 我正在开发Sony Xperia M(Android 4.1.2)。
You can set it in xml in the manifest file using : 您可以使用以下代码在清单文件中的xml中进行设置:
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. 另一种方法是将根布局的旋转设置为180度。 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 你应该用
android:screenOrientation="fullSensor"
,使取向在所有4个方向,如解释在这里
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. 如果启用了自动旋转功能,则在“全传感器”模式下初始化应用程序,然后根据配置更改或屏幕方向更改更改为“反向人像”,会将您的应用程序旋转到该模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.