我想隐藏一些 Activity 的标题栏。问题是我对所有 Activity 都应用了一种样式,因此我不能简单地将主题设置为 @android:style/Theme.NoTitleBar
。
使用 NoTitleBar 主题作为我的样式的父主题会从我的所有 Activity 中删除标题栏。
我可以在某处设置一个无标题样式的项目吗?
最佳答案
在您的 onCreate()
方法中执行此操作。
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
this
指的是Activity
。
关于android - 如何使用现有的自定义主题在 XML 中隐藏 Activity 的标题栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2591036/