public void fullScreenChange() {
SharedPreferences mPreferences = PreferenceManager
.getDefaultSharedPreferences(this);
boolean fullScreen = mPreferences.getBoolean("fullScreen", false);
WindowManager.LayoutParams attrs = getWindow().getAttributes();
System.out.println("fullScreen的值:" + fullScreen);
if (fullScreen) {
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
// 取消全屏设置
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mPreferences.edit().putBoolean("fullScreen", false).commit();
} else {
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
mPreferences.edit().putBoolean("fullScreen", true).commit();
}
}
在设置按钮中调用该方法,可动态改变全屏/非全屏