简体   繁体   English

在未启用“自动旋转屏幕”的情况下无法使用反向人像方向

[英]Can't use reverse portrait orientation without “Auto-Rotate Screen” enabled

What I'm trying to do 我想做什么

I'm trying to programmatically set the screen orientation to reverse portrait. 我正在尝试以编程方式将屏幕方向设置为反转纵向。

Problem 问题

The request to change the screen orientation only works for orientations other than reverse portrait. 更改屏幕方向的请求仅适用于纵向以外的方向。

What I've Tried 我尝试过的

  • Enabling the system-wide "Auto-Rotate Screen" setting seems to allow reverse portrait mode. 启用系统范围的“自动旋转屏幕”设置似乎允许反向纵向模式。 However, I don't want the app to require that this be enabled in order to work . 但是,我不希望该应用程序要求启用它才能正常工作。
  • Both setOrientation and the use of a system dialog to change the orientation. setOrientation和使用系统对话框来更改方向。 The problem occurs regardless of which method is used. 无论使用哪种方法,都会出现此问题。

Other info 其他资讯

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);

More on this here . 更多关于这里

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.

相关问题 Android:即使设备自动旋转屏幕关闭,如何强制反转肖像方向? - Android: How to force reverse portrait orientation even if the device auto-rotate screen is off? 旋转屏幕而不打开自动旋转 - Rotate screen without turn on auto-rotate 如何将方向设置为纵向模式,而不管 Android / React Native 中的自动旋转 - How to set orientation to portrait mode, regardless the auto-rotate in Android / React Native 设置自动旋转启用/禁用Android - Set Auto-Rotate Enabled/Disabled Android 了解设备方向是否已锁定(检测是否启用了自动旋转) - Find out if device orientation is locked (Detect if auto-rotate is enabled/disabled) 屏幕方向为纵向和反向纵向 - Screen orientation to portrait and reverse portrait 屏幕方向-反向肖像 - screen orientation - reverse portrait 在Android中禁用自动旋转后,如何收听屏幕方向变化? - How to listen to screen orientation change when auto-rotate is disabled in Android? 如何将自动方向限制为纵向和反向纵向 - How to limit auto orientation to portrait and reverse portrait 即使将方向设置为纵向,屏幕仍然可以旋转 - Screen still can rotate even if orientation is set to Portrait
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM