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. Android Camera代码位置
  2. Android Studio设置类代码模板
  3. Android PopupWindow动画效果代码
  4. Android获取高清app图标代码分享
  5. 收藏代码-Android状态栏工具代码
  6. Android 2.1 GPS定位和拍照功能代码
  7. android 震动和提示音的实现代码
  8. Android 内核源代码交叉编译纺

随机推荐

  1. Android(安卓)中基本图像绘制
  2. Android(安卓)闪电效果 (Electric Screen
  3. Android资源管理中的Theme和Style-------
  4. AsyncTask源码深入分析和巧记线程池
  5. 好的android程序该这样编写
  6. Android画布和图形绘制---Canvas and Dra
  7. getQuantityString
  8. android中使用代码混淆出现Conversion to
  9. Android实现信息安全中维吉尼亚密码技术
  10. Android(安卓)Studio导入jar后无法识别、