动态全屏设置 android

来源:互联网 发布:淘宝充值日亚礼品卡 编辑:程序博客网 时间:2024/04/28 07:38
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();}}

在设置按钮中调用该方法,可动态改变全屏/非全屏

0 0
原创粉丝点击