本文介绍了只有锁定方位两个方向 - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何才能让我的Andr​​oid应用程序是横向或纵向,但没有反方向?

How can make my android application to be Landscape or portrait but without the reverse directions?

含义,我想启用 SCREEN_ORIENTATION_PORTRAIT SCREEN_ORIENTATION_LANDSCAPE ,但禁用 SCREEN_ORIENTATION_REVERSE_LANDSCAPE SCREEN_ORIENTATION_REVERSE_PORTRAIT

Meaning that I want to enable SCREEN_ORIENTATION_PORTRAIT and SCREEN_ORIENTATION_LANDSCAPE but to disable SCREEN_ORIENTATION_REVERSE_LANDSCAPE and SCREEN_ORIENTATION_REVERSE_PORTRAIT.

感谢

推荐答案

我在我的相机应用了同样的问题/功能请求,并发现这篇文章:

I had the same problem/feature request in my camera app, and found this post:

android相机surfaceview方向

在changeRotation刚刚评 ORIENTATION_PORTRAIT_INVERTED ORIENTATION_LANDSCAPE_INVERTED ,并创建一个方法 rotateViews(INT度)常规横向/纵向之间切换时旋转的所有图像(按钮),你的布局。

In changeRotation just comment ORIENTATION_PORTRAIT_INVERTED and ORIENTATION_LANDSCAPE_INVERTED, and create a method rotateViews(int degrees) to rotate all of the images(buttons) of your layout when switching between regular landscape/portrait.

此外,

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR | ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

这篇关于只有锁定方位两个方向 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 11:41