首页 > 移动平台 > 详细

Android应用去掉标题栏的方法

时间:2016-01-10 19:44:45      阅读:182      评论:0      收藏:0      [点我收藏+]

1.在代码里实现

this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏,this指当前的Activity

这句代码一定要加在setContentView()前面。

技术分享
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
View Code

2.在清单文件里实现

技术分享
<application android:icon="@drawable/icon" 
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.NoTitleBar">
View Code

这样设置的是整个应用都为无标题栏,如果需要在某一个Activity设置成一个无标题栏的形式,只要把上面android:theme="@android:style/Theme.NoTitleBar"写到某一个Activity里面就可以了。

3.在style.xml文件里定义

技术分享
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="notitle">
        <item name="android:windowNoTitle">true</item>
    </style> 
</resources>
View Code

然后在清单文件中引用

技术分享
<application android:icon="@drawable/icon" 
        android:label="@string/app_name" 
        android:theme="@style/notitle">
View Code
技术分享
<application android:icon="@drawable/icon" 
        android:label="@string/app_name" 
        android:theme="@style/notitle">
View Code

其实第二种和第三种方法实质是一样的,第三种会更高大上一些。

 

Android应用去掉标题栏的方法

原文:http://www.cnblogs.com/earnking/p/5118916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!