即使纵向模式被锁定,Android 应用程序也会自动旋转到横向模式几秒钟
我不知道你们中是否有人以前见过这个:
我有一个应用程序,它为每个活动都锁定了纵向方向。然而,在 HTC Pro Touch 手机中(也许这种情况发生在其他带有物理键盘的手机上),应用程序会旋转到横向模式几秒钟,然后返回到纵向模式,这是在应用程序上导航时发生的。当然这不应该发生,但我不确定为什么会这样。
我通过在超类的 create 方法中调用 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) 来锁定纵向模式。
当我写这篇文章时,我意识到锁定指令是在 super.create(..) 之后调用的,这会有所不同吗? (测试需要一些时间,如果不是我现在就知道)。如果不是,我还能做什么来避免这种自动旋转?
先谢谢了,希望有人知道。
I don't know if any of you have seen this before:
I have an application which has the Portrait orientation locked for every activity. However, in the HTC Pro Touch phone (and maybe this happens on other phones with physical keyboards) the application rotates to landscape mode for a few seconds and then returns to portait mode, that happens while navigating on the app. Of course this shouldn't happen but I'm not sure why it does that.
I am locking the portrait mode by calling setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) in the create method of my super class.
While I was writting this I realized that the locking instruction is called after the super.create(..), could that make a difference? (Testing takes some time if not I would know right now). If not what else could I do to avoid this auto-rotation?
Thanks in advance, I hope someone knows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在清单中设置该属性。
除非你以后想改变方向。但这可能是最好的方法。
You should set the attribute in your manifest.
Unless you want to change the orientation later. But that is probably the best way to do it.