1. Java代码实现
@Overridepublic void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        requestWindowFeature(Window.FEATURE_NO_TITLE);         setContentView(R.layout.main);        //...}

留意这语句所在的位置的,似乎所有requestWindowFeature的操作都要放在setContentView的前面。

但使用这种方法,用户体验不太好,在Activity将要显示时,仍然会出现title bar,然后再去掉的。

2. 自定义style配置文件
在\res\values里面的style.xml添加:
<?xml version="1.0" encoding="utf-8"?><resources>        <style name="NoTitle" parent="android:Theme">                <item name="android:windowNoTitle">true</item>        </style></resources>

这里的代码应该看明白了吧!
然后在AndroidManifest.xml文件里,给需要去掉title bar的activity的节点上加上android:theme="@style/NoTitle,代码如下:
<activity android:name=".MainActivity"                    android:configChanges="orientation|keyboardHidden"                    android:theme="@style/NoTitle" />


3. 直接在AndroidManifest.xml中进行修改
原来我们可以无需自定义style配置的,直接调用系统的就行了:
<activity android:name=".MainActivity"                    android:configChanges="orientation|keyboardHidden"                    android:theme="@android:style/Theme.NoTitleBar" />


如果我们要设置整个Application都去掉title bar,那么就设置application:
<application android:icon="@drawable/lightbulb" android:label="@string/app_name"                    android:theme="@android:style/Theme.NoTitleBar">

更多相关文章

  1. Android4.1 Rotation 小结
  2. Android(安卓)EditText达到SearchView的效果
  3. android通过反射来获取系统属性SystemProperties
  4. Android(安卓)Camera代码位置
  5. android 自带的下拉刷新控件,含Demo(SwipeRefreshLayout控件)
  6. android之luncher滑动效果
  7. android 创建添加快捷方式
  8. Android(安卓)全屏无标题详解
  9. Android实现界面跳转

随机推荐

  1. Android开源游戏引擎之Angle(一)——概述
  2. 无需Root也能使用Xposed!
  3. 转:Android中自定义SeekBar的背景颜色,进度
  4. Android如何让你的第三方库可以compile的
  5. Android(安卓)多渠道打包(二)--动态多渠道资
  6. Android判断用户的网络类型(2/3/4G、wifi
  7. Android(安卓)RecyclerView删除多个选中
  8. Android(安卓)UI 卡顿及ANR检测原理
  9. Android学习之坑——静态广播问题
  10. Android学习笔记:获取相册和摄像机图片在A