【发布时间】:2012-05-26 23:54:06
【问题描述】:
我使用 OrientationEventListener 来检测方向,但我有一个问题,平板电脑是横向的,而手机默认是纵向的。这意味着 OrientationEventListener 为平板电脑上的肖像返回值 90,而在手机上为肖像返回 0。
我正在使用的活动有摄像头,因此我无法在方向之间更改,因此我使用 Orientation 的值根据需要重新定位屏幕上的几个元素。
是否可以检测设备是否是平板电脑,以便我可以相应地调整值。即如何计算 isTablet 的值?
if(isTablet)
{
orientation += -90;
if(orientation < 0) //Check if we have gone too far back, keep the result between 0-360
{
orientation += 360;
}
}
【问题讨论】:
标签: android mobile screen orientation tablet