【问题标题】:Samsung Galaxy Tab portrait orientation problems三星 Galaxy Tab 纵向问题
【发布时间】:2012-05-15 13:43:50
【问题描述】:

我正在制作一个应用程序,目前正在将其优化为三星 Galaxy Tab。 我这里有个小问题,当我启动应用程序时,它只出现在一个纵向。

我使用这个代码:

android:screenOrientation="portrait"

它只适用于一个纵向屏幕方向,所以如果我将设备旋转到倒置,它现在会发生变化。 这有点烦人,因为如果我以错误的方向启动应用程序,我的应用程序就会颠倒过来并且不会改变。

我能用这个做什么?

【问题讨论】:

标签: android tabs orientation portrait


【解决方案1】:

而不是设置 android:screenOrientation="portrait" , 如果您在 API 级别 9+,则应设置 android:screenOrientation="sensorPortrait"

更多信息:查看documentation

【讨论】:

    【解决方案2】:

    你可以试试Activity. setRequestedOrientation(int)

    参数可以是ActivityInfo.SCREEN_ORIENTATION_PORTRAITActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT

    【讨论】:

      【解决方案3】:

      在 onCreate() 调用 super.onCreate() 之前调用下面的方法......它应该可以工作......

      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-31
        • 1970-01-01
        • 1970-01-01
        • 2018-07-28
        相关资源
        最近更新 更多