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

ⅰ亾dé卋堺 提交于 2019-12-11 06:48:12

问题


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).

As the user tilts the device left and right, the angle adjusts accordingly. And as it rotates I want to simply update a 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.

Can anybody forward me in the right director, or provide some information?

Thank you very much!


回答1:


You implement OrientationEventListener this will give you the device rotation. Portrait is 0 degree.



来源:https://stackoverflow.com/questions/15737762/get-rotation-tilt-angle-in-landscape-view-android-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!