如何检查设备自然(默认)方向上的Andr​​oid(即获得景观的如摩托罗拉Charm或FLIPOUT) [英] How to check device natural (default) orientation on Android (i.e. get landscape for e.g., Motorola Charm or Flipout)

查看:130
本文介绍了如何检查设备自然(默认)方向上的Andr​​oid(即获得景观的如摩托罗拉Charm或FLIPOUT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经显示了从摄像头preVIEW一个活动,所以需要将只设置景观。在底部(不考虑设备旋转的)我想显示一个文本视图。我使用OrientationEventListener赋予其天然位置设备的方向。我可以实现一个解决方案,在肖像默认设备运行良好,但使它也可以用在我需要知道这种设备上运行的景观默认设备。因此,问题是如何检查呢?

I have an activity showing preview from camera, so it need to be set as landscape only. At the bottom (regardless of device rotation) I want to show a text view. I am using OrientationEventListener which gives device's orientation from its natural position. I can implement a solution which works well on portrait default devices but to make it work also on landscape default devices I need to be aware of running on such a device. Thus the question is how to check it?

推荐答案

这是可以做到使用的 Display.getOrientation()或的 Display.getRotation()(对于API级别> = 8)。

It can be done using Display.getOrientation() or Display.getRotation() (for API level >= 8).

这篇关于如何检查设备自然(默认)方向上的Andr​​oid(即获得景观的如摩托罗拉Charm或FLIPOUT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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