Android的 - 检测方向变化,但界面不响应 [英] Android - detect orientation change, but have interface not respond

查看:286
本文介绍了Android的 - 检测方向变化,但界面不响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

采用的是Android可以捕捉屏幕旋转事件,但实际上并没有活性,旋转响应事件?

Is it possible in Android to capture screen rotate events but not actually have the activity respond to the rotate events?

为了让事情变得更加困难,我有一个TabActivity支持的活动,并在我想旋转的一些内容区域在屏幕上的标签之一 - 但在纵向模式下离开标签

To make things more difficult, I've got an activity backed by a TabActivity, and in one of the tabs I want to rotate some of the content area on screen - but leave the tab in portrait mode.

我试过设置活动方向为纵向的清单,但后来我不再让onConfigurationChanged(..)事件。但是,如果我删除此行,整片旋转为好。

I've tried setting the activity orientation to portrait in the manifest, but then I no longer get the onConfigurationChanged(..) events. However, If I remove this line, the whole tab rotates as well.

任何帮助AP preciated!

Any help appreciated!

推荐答案

设置方向为纵向模式中的表现为你做,而是直接听取加速度传感器(这是从Android的派生的方向传感器设备)更新和自己分析他们知道什么时候该方向改变。

Set the orientation to portrait mode in the manifest as you did, but listen directly to the accelerometer sensor (which is the sensor from which Android derives the orientation of the device) updates and parse them yourself to know when the orientation changed.

这其实很容易做到。看到这里的一个例子: http://www.anddev.org/accessing_the_accelerometer-t499.html

It's actually quite easy to do. See here for an example: http://www.anddev.org/accessing_the_accelerometer-t499.html

这篇关于Android的 - 检测方向变化,但界面不响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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