在android开发中时常会碰到要全屏显示程序的时候,有2个方法可以解决这个问题
一个是在Activity的setContextView()方法之前调用
- //隐藏标题栏
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- //隐藏状态栏
- this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
还有一种是修改AndroidManifest.xml 。
无标题栏-----在application 标签中添加android:theme="@android:style/Theme.NoTitleBar"
无标题栏和状态栏-----application 标签中添加android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
自定义标题栏
在AndroidMenifest.xml中
在titlebar.xml中
在styles.xml中
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="activityTitlebar" parent="android:Theme">
<item name="android:windowTitleSize">30dp</item>
<item name="android:windowTitleBackgroundStyle">@style/titleBackground</item>
</style>
<style name="titleBackground">
<item name="android:background">#DCDCDC</item>
</style>
</resources>
同时还要在java代码中写上
就可以改变窗口标题栏的样式。