第一种:也一般入门的时候经常使用的一种方法

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

注意这句一定要写在setContentView()方法的前面,不然会报错的

或者

  1. @Override
  2. publicvoidonCreate(BundlesavedInstanceState){
  3. super.onCreate(savedInstanceState);
  4. setContentView(R.layout.main);

  5. ActionBaractionBar=getActionBar();
  6. actionBar.hide();
  7. //actionBar.show(); }

第二种:在AndroidManifest.xml文件中定义

< application android:icon = " @drawable/icon "
android:label
= " @string/app_name "
android:theme
="@android:style/Theme.NoTitleBar" >

可以看出,这样写的话,整个应用都会去掉标题栏,如果只想去掉某一个Activity的标题栏的话,可以把这个属性加到activity标签里面

第三种:这种在一般的应用中不常用,就是在res/values目录下面新建一个style.xml的文件

例如:

<? xml version="1.0" encoding="UTF-8" ?>
< resources >
< style name ="notitle" >
< item name ="android:windowNoTitle" > true </ item >
</ style >
</ resources >

这样,我们就自定义了一个style,就相当于一个主题,然后在AndroidManifest.xml文件中定义

< application android:icon ="@drawable/icon"
android:label
="@string/app_name"
android:theme
="@style/notitle" >

这样也可以达到去掉标题栏的效果

三种去掉标题栏方法的总结

第一种,有的时候我们会看到,会先出现标题栏,然后再消失,因为我们只是在activity的oncreate方法中定义的,第二种相对第一种比较好一些,不会出现这种情况,第三种我个人感觉最好,这样把功能分开,便于维护和扩展

再介绍全屏的方法:

第一种

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

第二种

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

第三种

application android:icon ="@drawable/icon"
android:label
="@string/app_name"
android:theme
="@style/fullscreem"

更多相关文章

  1. 一款常用的 Squid 日志分析工具
  2. GitHub 标星 8K+!一款开源替代 ls 的工具你值得拥有!
  3. RHEL 6 下 DHCP+TFTP+FTP+PXE+Kickstart 实现无人值守安装
  4. Linux 环境下实战 Rsync 备份工具及配置 rsync+inotify 实时同步
  5. android Eclipse执行项目提示错误: unable to execute dex: GC or
  6. android源码单独编译的方法
  7. Eclipse导入Android项目的正确方法
  8. Hello Android(安卓)- Android(安卓)对话框大全
  9. Android之JNI:Android(安卓)Studio使用Gradle编译C/C++源码

随机推荐

  1. Android(安卓)API Differences Report
  2. Android(安卓)4.0 的 GridLayout
  3. android键盘事件
  4. Android滑动卡片效果:Swipecards
  5. Android添加单元测试的方法与步骤
  6. Android自动化测试之monkeyrunner基本要
  7. input 之我见1
  8. Android(安卓)SDK的docs访问速度很慢
  9. 2010.12.14——— android 应用的自动更
  10. android图片闪烁或帧动画