简体   繁体   English

Android应用程序的屏幕方向

[英]Screen orientation of an android application

是否可以在android清单文件中编写代码,该文件会根据设备屏幕尺寸自动更改屏幕方向?

May this help you: 可以帮助您:

Instead of fixing the orientation on the manifest, you could use setRequestedOrientation . 您可以使用setRequestedOrientation而不是在清单上固定方向。 On the onCreate method of each activity, check if you are on a tablet or smartphone and set the desired orientation. 在每个活动的onCreate method上,检查您是在平板电脑还是智能手机上,并设置所需的方向。

Another option could be Creating Multiple APKs for Different Screen Sizes , depending on your needs. 另一种选择是根据您的需要为不同的屏幕尺寸创建多个APK

As far as I know this cannot be done in the manifest. 据我所知,这不能在清单中完成。 However, you can write some code to achieve this. 但是,您可以编写一些代码来实现此目的。 Have a look at the setRequestedOrientation method of Activity . 看一下ActivitysetRequestedOrientation方法。 Details in the documentation . 文档中的详细信息。

However, this will probably not generate the best user experience. 但是,这可能不会产生最佳的用户体验。

AFAIK Tablets have default orientation set to Landscape. AFAIK数位板的默认方向设置为“横向”。 So this should automatically handled 所以这应该自动处理

在您定义的Androidmanifest.xml中的Activity中,写出以下内容,

 android:screenOrientation="unspecified"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM