我正在尝试为我的应用程序强制"纵向"模式,因为我的应用程序绝对不是为"横向"模式设计的.
在阅读了一些论坛后,我在清单文件中添加了这些行:
<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)
但同样,没有运气.