我想给程序只设置竖向模式,而不用横向模式。
在网上查了些资料后,我在 manifest文件中添加了:
<application
android:debuggable="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:screenOrientation="portrait">
但是在我的移动设备中(这里指HTC设备)不能正确运行,依旧会从竖向模式转向横向模式。
然后又在代码中添加:
<application
android:debuggable="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:configChanges="orientation"
android:screenOrientation="portrait">
在Activity中加入这个功能:
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
依然在旋转。请问如何能让设备只显示竖向模式,不显示横向模式呢?