您的位置:首页 > 移动开发 > Android开发

动态全屏设置 android

2014-04-27 12:31 330 查看
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();
}
}

在设置按钮中调用该方法,可动态改变全屏/非全屏
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息