android全屏和取消全屏 旋转屏幕
全屏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 取消全屏 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //把屏幕设置为横屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); //把屏幕设置为竖屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//横竖屏切换
android.view.ViewGroup.LayoutParams layoutParams = main .getLayoutParams(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { // 设置为横屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 横屏设置 layoutParams.height = screenHeight; mTitleBarRl.setVisibility(View.GONE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 竖屏设置 layoutParams.height = original_height; mTitleBarRl.setVisibility(View.VISIBLE); } main.setLayoutParams(layoutParams);