简体   繁体   English

加速度传感器在横向模式下的设置与纵向设置相同

[英]Accelerometer sensor keep same settings on landscape mode as portrait

Im using Accelerometer sensor in my app. 我在我的应用中使用了加速度传感器。 I want the degres for the Accelerometer stays the same on landscape mode as portrait mode. 我希望加速度计的设备在横向模式下保持与纵向模式相同。 Because when i have it in portrait mode the numbers is like this photo http://imgur.com/22bWoq5,HLJJi2V and in landscape mode it gives this numbers http://imgur.com/22bWoq5,HLJJi2V#1 . 因为当我将其设置为纵向模式时,数字就像这张照片http://imgur.com/22bWoq5,HLJJi2V,而在横向模式中,它给出的数字是http://imgur.com/22bWoq5,HLJJi2V#1

Well, according to documentatiion this is proper behaviour. 好吧,根据文献记载,这是正确的行为。 When you phone is in portrait mode, different forces affects your sensors thenwhen phone is in landscape orientation. 当手机处于纵向模式时,当手机处于横向时,不同的力会影响传感器。

There is no simple way to make those values stay the same in both mode, you cannot changes the laws of physics :) 没有简单的方法可以使这些值在两种模式下保持相同,您不能更改物理定律:)

If you really want to use those readings, either you can set fixed activity orientations (always portrait or always landscape) but still, if you rotate yoor phone, readings will change. 如果您确实要使用这些读数,则可以设置固定的活动方向(始终为纵向或始终为横向),但是如果您旋转手机,读数也会发生变化。

The second option is to check for screen orientation in runtime and thane reffer to proper sensor value. 第二个选项是在运行时检查屏幕方向,然后返回到正确的传感器值。

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

相关问题 如何在横向和纵向模式下开始相同的活动? - How to start the same activity in landscape and in portrait mode? 从肖像模式到风景模式问题 - From Portrait to Landscape mode issue 缩放后图像处于横向而不是纵向模式 - Image is in landscape instead of portrait mode after scaling 如何使用libGDX在纵向和横向模式之间切换? - How to switch between portrait and landscape mode with libGDX? 如何在同一Java类中将两个传感器管理器用于加速度计和磁力计 - How to use Two Sensor Manager for Accelerometer and Magnetometer in the same Java class 如何在我的活动处于横向状态时以纵向模式打开NavigationDrawer? - How to open NavigationDrawer in portrait mode while my activity is in landscape? 如何设置几个片段是横向模式和休息应该是Android中的肖像? - How to set few fragment be landscape mode and rest should be portrait in android? Android LinearLayout在横向和纵向模式下将元素放置在中间 - Android LinearLayout place elements in the middle with landscape and portrait mode 使用itextpdf,横向和纵向之间PDF的PageSize始终相同 - PageSize of PDF always the same between landscape and portrait with itextpdf 如何使用Android 5.0在纵向模式下保持屏幕方向? - How to keep screen orientation in portrait mode with Android 5.0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM