简体   繁体   English

在横向视图中获取旋转(倾斜)角度-Android Java

[英]Get Rotation (Tilt) Angle In Landscape View - Android Java

I've scrounged the web in search of a good example or someone trying to attempt the same thing, but so far I haven't had much luck. 我搜寻网络是为了寻找一个好榜样或有人试图尝试相同的事情,但是到目前为止我还没有多大运气。

I am trying to get my Devices rotation angle (If you can imagine) starting at 180° (Flat). 我正在尝试让我的设备旋转角度(如果可以想象)从180°(平坦)开始。

As the user tilts the device left and right, the angle adjusts accordingly. 当用户左右倾斜设备时,角度会相应调整。 And as it rotates I want to simply update a TextView. 随着旋转,我只想更新一个TextView。

I'm just lost as to what this evolves, some people suggest a gyroscope, accelerometer, even a magnometer, or a combination. 我只是对它的发展一无所知,有人建议使用陀螺仪,加速度计,甚至是陀螺仪或它们的组合。 I've gotten a few different sensors to work, but none of the examples I've followed accomplish what I want to achieve. 我已经使用了几种不同的传感器,但是我所遵循的所有示例都没有实现我想要实现的目标。

I don't want anything to do with 3D, just a plan rotation. 我不想与3D有任何关系,只是计划旋转。

Can anybody forward me in the right director, or provide some information? 谁能在合适的导演中转发我,或提供一些信息?

Thank you very much! 非常感谢你!

You implement OrientationEventListener this will give you the device rotation. 您实现OrientationEventListener可使设备旋转。 Portrait is 0 degree. 人像为0度。

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

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