首页 > 移动平台 > 详细

Android 标题栏之隐藏

时间:2016-02-23 12:49:06      阅读:151      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!