去掉android的屏幕上的title bar
去掉屏幕上的title bar有3个方法:
1. Java代码实现
@Override
public 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">
title bar还能够自定义的,请查看文章《自定义Activity标题栏(Title bar)》
相关新闻>>
- 发表评论
-
- 最新评论 更多>>
今日头条
更多>>您可能感兴趣的文章
- 基于Android NDK的学习之旅-----JNI LOG打印
- Android自定义PopupWindow实现的Menu(TabMenu)
- Android开发之Android体系架构介绍
- Android TextView中设定个别文字字体显示格式
- Android开发者指南(2) —— aapt
- Android[中级教程]第一章 数据存储之Shared Preferenc
- 自定义ListView背景(解决了拖动变黑的效果)
- Android项目代码混淆
- android平板上的GridView视图缓存优化
- Ubuntu 10.10 64bit下使用Android NDK r6编译FFmpeg 0.8.1