Android去掉标题栏和全屏

来源:互联网 发布:淘宝童模招聘 编辑:程序博客网 时间:2024/06/10 04:04
转载地址:http://www.ciitn.com/chanye/xitong/android/20110426_570.html


Android去掉标题栏和全屏都是件很容易的事情,最常见的有两种方法: 第一:在程序代码中实现 Java代码this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowMana


Android去掉标题栏和全屏都是件很容易的事情,最常见的有两种方法:
第一:在程序代码中实现
Java代码this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏


this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏


this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏


this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
注意:这两行代码要写在页面显示之前,即setContentView(R.layout.XXX)之前
第二:在AndroidManifest.xml配置文件中实现标签android:theme
Java代码<activity android:name="Activity1"


android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>


<activity android:name="Activity1"


android:theme="@android:style/Theme.NoTitleBar.Fullscreen"></activity>
注意:如果不需要全屏,只需要写成android:theme="@android:style/Theme.NoTitleBar即可
总结:二者的区别
如果使用第一种方法,在Activity启动时会有短暂的标题栏和信息栏的出现,随后会消失。
使用第二种方法这不会出现这种情况,个人推荐使用第二种方式,看起来比较流畅。
 
原创粉丝点击