简体   繁体   English

将屏幕方向锁定为仅一种风景和一种肖像模式

[英]Lock screen orientation to just one landscape and one portrait modes

Let's say my app has two activities A and B . 假设我的应用有两个活动AB And, also, let's call the posible screen orientations landscape-1 , portrait-2 , landscape-3 and portrait-4 . 并且,我们也将可能的屏幕方向称为landscape-1portrait-2landscape-3portrait-4
I would like to lock the orientation of A to landscape ( 1 and 3 ), and B to both landscape and portrait ( 1 , 2 , 3 and 4 ). 我想的取向锁定A为横向( 13 ),和B向横向和纵向( 1234 )。 So, to do this, I used sensorLandscape . 因此,为此,我使用了sensorLandscape Later I realized that sensorLandscape is for API 9 or greater, and I want to support older versions. 后来我意识到sensorLandscape适用于API 9或更高版本,并且我想支持旧版本。 I searched for a way to emulate sensorLandscape behaviour, but I didn't find anything. 我搜索了一种模拟sensorLandscape行为的方法,但没有找到任何东西。 So I'm now going for a simpler approach: I would like to use landscape mode on activity A (this is, just 1 ), but I don't want the user to be able to use landscape-3 on activity B (so there's no weird turning when going back to activity A ). 因此,我现在打算采用一种更简单的方法:我想在活动A上使用landscape模式(这只是1 ),但是我不希望用户能够在活动B上使用landscape-3 (因此回到活动A )没有奇怪的转折。
To sum up , the idea is the following: 综上所述 ,其思路如下:
Posible screen orientations for activity A : landscape-1 . 活动A可能屏幕方向: landscape-1
Posible screen orientations for activity B : landscape-1 and portrait-3 . 活动B可能屏幕方向: landscape-1portrait-3
Any ideas on how to accomplish this behaviour? 关于如何完成此行为的任何想法?

Use it and don't support api <13 just because no need to make extra work 使用它并且不支持api <13只是因为不需要做额外的工作

Done is better than perfect 做完比求完美强

Don't worry you are still targeting 97% of Android Users with Api >=9. 不用担心,您仍然将Api> = 9定位为97%的Android用户。

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

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