android studio怎么取消自带导航栏

heiu

android studio创建默认app总是自带一个导航栏,尤其不好看,而且对某些手机总和手机自己的时间状态栏打架。

搞了好几种办法取消了,然后进行优化布局还不错

1
2
3
4
5
6
// 隐藏 ActionBar
supportActionBar?.hide()

// 如果使用 Toolbar 替代 ActionBar
// setSupportActionBar(toolbar)
// supportActionBar?.hide()
1
2
3
4
5
6
// 显示时间状态栏并设置状态栏文字为深色
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// 隐藏ActionBar
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}

相较于java,kt更能简单

  • 标题: android studio怎么取消自带导航栏
  • 作者: heiu
  • 创建于 : 2025-03-09 22:40:31
  • 更新于 : 2025-03-22 09:00:59
  • 链接: https://www.heiu.top/posts/e96907e1.html
  • 版权声明: 版权所有 © heiu,禁止转载。
评论
目录
android studio怎么取消自带导航栏