强制竖屏设置
1.代码在Activity的onResume方法中添加如下代码
@Override
protected void onResume() {
/**
* 设置为横屏
*/
if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
super.onResume();
}
2.在配置文件中对Activity节点添加android:screenOrientation属性(landscape是横向,portrait是纵向)
android:launchMode="singleTask" android:screenOrientation="landscape">
网友评论