/**
*设置全屏
*/
public void setupFullScreen(){
WindowManager.LayoutParams attrs = getWindow().getAttributes();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
//获取屏幕尺寸
WindowManager manager = this.getWindowManager();
DisplayMetrics metrics = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(metrics);
//设置Video布局尺寸
mVideoLayout.getLayoutParams().width = metrics.widthPixels;
mVideoLayout.getLayoutParams().height = metrics.heightPixels;
mIsFullScreen = true;
}
/**
* no全屏
*/
private void setupUnFullScreen() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
float width = getResources().getDisplayMetrics().heightPixels;
float height = dp2px(200.f);
mVideoLayout.getLayoutParams().width = (int) width;
mVideoLayout.getLayoutParams().height = (int) height;
//设置为全屏
mIsFullScreen = false;
}
最近公司在开发vr播放器,做到播放器点击右下角全屏半屏切换时遇到问题,就查了些资料整理了哈 送个需要的人