相关疑难解决方法(0)

强制"纵向"方向模式

我正在尝试为我的应用程序强制"纵向"模式,因为我的应用程序绝对不是为"横向"模式设计的.

在阅读了一些论坛后,我在清单文件中添加了这些行:

<application 
  android:debuggable="true"
  android:icon="@drawable/icon" 
  android:label="@string/app_name"
  android:screenOrientation="portrait">
Run Code Online (Sandbox Code Playgroud)

但它不适用于我的设备(HTC Desire).它从"纵向"lo"横向"切换,忽略清单文件中的行.

在更多论坛阅读之后,我尝试在我的清单文件中添加它:

<application 
  android:debuggable="true"
  android:icon="@drawable/icon" 
  android:label="@string/app_name"
  android:configChanges="orientation"       
  android:screenOrientation="portrait">
Run Code Online (Sandbox Code Playgroud)

这个函数在我的activity类中:

public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Run Code Online (Sandbox Code Playgroud)

但同样,没有运气.

android landscape portrait screen orientation

285
推荐指数
5
解决办法
22万
查看次数

标签 统计

android ×1

landscape ×1

orientation ×1

portrait ×1

screen ×1