码迷,mamicode.com
首页 > 移动开发 > 详细

Android 标题栏之隐藏

时间:2016-02-23 12:51:22      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

隐藏标题栏

方法【1】、 在Activity的OnCreate()方法里加上requestWindowFeature(Window.FEATURE_NO_TITLE);

        即:(记住:这句代码要写在setContentView()前面)

void onCreate(Bundle savedInstanceState) {  
    ...               
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    ...
}

 

方法【2】、 在配置文件AndroidManifest.xml中,关键在android:theme=""

      (1)隐藏整个项目的标题栏: 

        //-->这里的theme引用的是系统自带的style 

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

        //-->这里的theme引用的是自定义的style

先在style.xml里添加 

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

然后在AndroidManifest.xml中引用

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

      (2)隐藏某个Activity的标题栏:

<activity
    android:name="某个acivity的包路径"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar" //这里的theme可以用自定义
</activity>

 

Android 标题栏之隐藏

标签:

原文地址:http://www.cnblogs.com/zajule/p/5209419.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!