美文网首页
Android 显示隐藏状态栏

Android 显示隐藏状态栏

作者: 糖糖_Fun | 来源:发表于2016-05-25 15:19 被阅读0次

Android 显示隐藏状态栏,小说阅读界面要用到

/** 
  * 显示隐藏状态栏,全屏不变,只在有全屏时有效 
  * @param enable 
  */
private void setStatusBarVisibility(boolean enable) {
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    if (enable) {
        lp.flags |= WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
    } else {
        lp.flags &= (~WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    }
    getWindow().setAttributes(lp);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
/**
 * 设置是否全屏
 * @param enable
 */
private void setFullScreen(boolean enable) {
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    if (enable) {
        lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
    } else {
        lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    getWindow().setAttributes(lp);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

相关文章

网友评论

      本文标题:Android 显示隐藏状态栏

      本文链接:https://www.haomeiwen.com/subject/xydtdttx.html