如何在电话中仅启用纵向和反向纵向,如何在传感器中启用"sensorPortrait"?在手机上不工作? [英] How to enable only portrait and reverse portrait in phones, "sensorPortrait" not working on phones?

查看:116
本文介绍了如何在电话中仅启用纵向和反向纵向,如何在传感器中启用"sensorPortrait"?在手机上不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚为什么在清单中为活动设置"sensorPortrait"属性不能使活动变为反向肖像.这就是我在清单中设置的方式

I cant figure out why setting "sensorPortrait" attribute in manifest for an activity doesn't work to allow the activity to go into reverse portrait. This is how I set in manifest

    <activity
        android:name=".MainActivty"
        android:label="Testing"
        android:screenOrientation="sensorPortrait"
        android:windowSoftInputMode="stateHidden"
        android:configChanges="orientation">
    </activity>

上面的代码对我来说无法在Moto E(4.4.4)或Galaxy S3(4.3)上同时获取反向肖像和肖像,但是我可以确认它在Nexus 7(5.0.1)平板电脑上可以正常工作,我尝试了其他几个答案,但是这个答案似乎是最简单的,并且似乎在电话"上对我不起作用,我是否缺少一些与使此方法正常工作相关的信息?

The above code is not working for me to get both reversePortrait and portrait on Moto E(4.4.4) or Galaxy S3(4.3), but I can confirm it works on a Nexus 7(5.0.1) tablet, I tried several other answers but this one seems to be the easiest and it is seemingly not working for me on 'phones', am I missing some information that is relevant for getting this to work?

我尝试了以下链接,该链接与我的问题类似,但似乎对此没有帮助

I tried the following link which is just as similar as my question but nothing seems helpful regarding this

仅纵向或反纵向活动

当前带有标志"sensorPortrait"的行为就像在手机中设置肖像"一样.

Currently with the flag "sensorPortrait" it behaves just like setting "portrait", in phones.

推荐答案

如果您查看

If you look at the PhoneWindowManager source code, you can see that it checks for the internal value config_allowAllRotations and uses that to determine if the 180 degree rotation (i.e., reverse portrait on phones) is allowed.

使用默认值为false ,这意味着在手机上禁用了反向肖像.您会注意到, sw600dp值(即平板电脑)是正确的,因此,为什么可以在平板电脑设备上使用所有旋转方式(包括反向肖像).

With a default value to false, this means that reverse portrait is disabled on phones. You'll note that the sw600dp value (i.e., tablets) is true, hence why you can use all rotations including reverse portrait on tablet devices.

这篇关于如何在电话中仅启用纵向和反向纵向,如何在传感器中启用"sensorPortrait"?在手机上不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆