Android处理方向的改变W / O旋转屏 [英] Android handle orientation change w/o rotating screen

查看:145
本文介绍了Android处理方向的改变W / O旋转屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理屏幕方向没有旋转屏?

How to handle screen orientation without rotating screen?

我必须重写 onConfigurationChanged 在我的活动,并尝试注释掉调用 super.onConfigurationChanged 和我的应用程序强制关闭。我试着下一件事情就是在这个方法的参数NEWCONFIG方向属性设置为 newConfig.orientation = Configuration.ORIENTATION_PORTRAIT;呼叫之前 super.onConfigurationChanged 。但是还是我的屏幕旋转了。

I have override onConfigurationChanged in my activity and try to comment out call super.onConfigurationChanged and my application Force Closes. Next thing I've tried was to set orientation attribute in newConfig parameter of this method to newConfig.orientation = Configuration.ORIENTATION_PORTRAIT; before call super.onConfigurationChanged. But still my screen has rotated.

我最后的实施将处理传感器(陀螺仪)的运动。但是否有任何其他方式做到这一点?

My last implementation would be to handle sensor (gyroscope) movement. But is there any other way to do this?

任何其他的想法?

推荐答案

在您的清单文件,将它添加到你的活动,你不想旋转:

In your manifest file, add this to your activity which you don't want to rotate:

android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"

从不断旋转的,包括如果手机有键盘进行幻灯片这将prevent它。

This will prevent it from ever rotating, including if the phone has a slide out keyboard.

我希望这有助于。

这篇关于Android处理方向的改变W / O旋转屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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