【问题标题】:android:screenOrientation tag in application does not work应用程序中的 android:screenOrientation 标签不起作用
【发布时间】:2011-02-21 05:38:23
【问题描述】:

android:screenOrientation 标签放在<application> 中时不起作用。 但是当我将android:screenOrientation 放在<activity> 标签中时,它就可以工作了。

如果android:screenOrientation 标记在<application> 中有效,则无需为每个活动放置android:screenOrientation 处理。

我想知道,为什么screenOrientation标签在Android平台上会有这么奇怪的行为?

【问题讨论】:

  • 当放置在..什么?水 ? ;)
  • 请重新表述您的问题。
  • 我相信他在问为什么 screenOrientation 不是 的属性,而只是 的属性。放大镜?
  • 我们可以把 android:screenOrientation="portrait" 放在 中对吧?并且也在 中。如果我将 android:screenOrientation="portrait" 放在 中,那么当手机/模拟器旋转时,应用程序仍然允许横向。当 android:screenOrientation="portrait" 放置在应用程序的每个活动中时,它只允许纵向模式。所以我的问题是,当 android:screenOrientation="portrait" 放置在 标签中时,android 为什么不允许应用程序的每个活动都使用纵向模式。

标签: android screen-orientation


【解决方案1】:

<application> 元素不支持android:screenOrientation。您可以通过reading the documentation 告诉您。

至于为什么<application> 元素不支持它,我想这至少部分是因为您不应该在许多活动中使用它,也许不是所有活动。

例如,您提议的android:screenOrientation="portrait" 根本不应该完成,几乎永远也不应该完成。 landscape我可以理解,对于某些类型的活动(相机、视频播放器、一些游戏)。但是portrait 的意思是:

  • 您不希望用户能够使用他们的侧滑硬件键盘
  • 您不希望用户能够在 Android 自然横向模式下使用他们的平板电脑
  • 您不想在 Google TV 上运行

android:screenOrientation 应仅用于那些绝对必须处于该方向的活动。否则,请尊重您的用户对使用哪个方向的意愿。不允许您为整个应用程序设置它只是帮助确保您真正考虑给定活动是否需要它的一种方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-05
    • 2012-12-06
    • 2020-08-03
    • 2018-12-11
    相关资源
    最近更新 更多