android开发全屏切换代码,记录一下

private void tryFullScreen(boolean fullScreen) {
  if (activity instanceof AppCompatActivity) {
    ActionBar supportActionBar = ((AppCompatActivity) activity).getSupportActionBar();
    if (supportActionBar != null) {
      if (fullScreen) {
        supportActionBar.hide();
      } else {
        supportActionBar.show();
      }
    }
  }
  setFullScreen(fullScreen);
}

private void setFullScreen(boolean fullScreen) {
  if (activity != null) {
    WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
    if (fullScreen) {
      attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
      activity.getWindow().setAttributes(attrs);
      activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    } else {
      attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
      activity.getWindow().setAttributes(attrs);
      activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
  }
}

 

android开发全屏切换代码,记录一下

上一篇:web前端入门到实战:CSS 滚动捕捉技术(Scroll Snapping)


下一篇:mapstruct 实体转换及List转换,@Mapper注解转换