android应用中去掉标题栏的方法

在style.xml文件里定义

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

然后在manifest.xml中引用就可以了

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

 

如果错误描述为

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

 

原因:
从错误提示中提到Theme.AppCompat theme,这是因为我们的activity一定是继承了兼容包中的类,
比如我这里就无意中继承了ActionBarActivity,它来自android.support.v7.app.ActionBarActivity。
所以就要使用与其配合的AppCompat的theme才行。

posted @ 2015-07-28 11:13  好吧的啊  阅读(148)  评论(0编辑  收藏  举报