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

在android中去掉标题栏有三种方法,它们也有各自的特点。

1.在代码里实现

this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 

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

2.在清单文件(manifest.xml)里面实现

<application android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"> 
<span style="font-family:Verdana;font-size:18px;"><application android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"></span>

这样用可以将整个应用设置成无标题栏,如果只需要在一个Activity设置成一个无标题栏的形式,只要把上面的第三行代码写到某一个Activity里面就可以了。

3.在style.xml文件里定义

<?xmlversion="1.0"encoding="UTF-8"?>
<resources>
   <style name="notitle">
        <item name="android:windowNoTitle">true</item>
   </style>
</resources> 
<span style="font-family:Verdana;font-size:18px;"><?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="notitle">
        <item name="android:windowNoTitle">true</item>
    </style>
</resources></span>

然后面manifest.xml中引用就可以了,这种方法稍麻烦了些。

<applicationandroid:icon="@drawable/icon"
        android:label="@string/app_name"
       android:theme="@style/notitle"> 
<span style="font-family:Verdana;font-size:18px;"><application android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/notitle"></span>

其实可以看得出来,第二种方法和第三种方法实质是一样的,只不过第二种方法调用的是系统定义好的style.xml文件,而第三种方法则是在自己的应用里定义style.xml,然后再自己再调用,其实道理是一样的,第三种方法做起来更有成就感。

时间: 2024-08-01 22:46:51

android应用中去掉标题栏的三种方法的相关文章

Android开发之去掉标题栏的三种方法,推荐第三种

Android:去掉标题栏的三种方法和全屏的三种方法 第一种:一般入门的时候经常使用的一种方法 onCreate函数中加入以下代码: requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 注意这句一定要写在setContentView()方法的前面,不然会报错的 第二种:在AndroidManifest.xml文件中定义 <application android:icon="@drawable/icon" android:la

Android开发中完全退出程序的三种方法

参考: http://android.tgbus.com/Android/tutorial/201108/363511.shtml Android程序有很多Activity,比如说主窗口A,调用了子窗口B,在B中如何关闭整个Android应用程序呢? 这里给大家三种比较简单的方法实现. 首先要说明在B中直接使用finish(),接下来手机显示的还是主窗口A,所以一起来看看是如何实现的吧. 1. Dalvik VM的本地方法 android.os.Process.killProcess(andro

spring在xml文件中配置bean的三种方法

一.最常见,也是缺省,是调用spring的缺省工厂类 spring缺省工厂类:org.springframework.beans.factory.support.DefaultListableBeanFactory使用其静态方法preInstantiateSingletons() 配置文件中最普通最基本的定义一个普通bean<bean id="DvdTypeDAOBean" class="com.machome.dvd.impl.DvdTypeDAO" >

Openerp 中打开 URL 的三种 方法

来自:http://shine-it.net/index.php/topic,8013.0.html 最近总结了,Openerp 中打开 URL 的三种 方法: 一.在form view 添加 <a>标签 二.使用url widget, <field name="field_name" widget="url"/> 三.使用按钮,return { 'type': 'ir.actions.act_url', 'http://www.opener

C#中datatable导出excel(三种方法)

方法一:(拷贝直接可以使用,适合大批量资料, 上万笔)Microsoft.Office.Interop.Excel.Application appexcel = new Microsoft.Office.Interop.Excel.Application();SaveFileDialog savefiledialog = new SaveFileDialog();System.Reflection.Missing miss = System.Reflection.Missing.Value;ap

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

转自  http://blog.csdn.net/liuzhidong123/article/details/7818531 现在我坚定的认为写技术博客对自己有很大的帮助,写博客给自己一个学而思的机会. 在android中去掉标题栏有三种方法,它们也有各自的特点. 1.在代码里实现 this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 记住:这句代码要写在setContentView()前面. 2.在清单文件(manifest.xm

android 自定义控件中获取属性的三种方式(转)

第一种方法,直接设置属性值,通过attrs.getAttributeResourceValue拿到这个属性值. (1)在xml文件中设置属性值 <com.example.activity.IconTextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/smile1" iconSrc="

cocos2dx中创建动画的三种方法

1.最最原始的方法,先创建动画帧,再创建动画打包(animation),再创建动画(animate) 第一步: 创建动画帧:CCSpriteFrame,依赖于原始的资源图片(xx.png,xx.jpg) CCSpriteFrame *frame1=CCSpriteFrame::create("1.png"); CCSpriteFrame *frame2=CCSpriteFrame::create("2.png"); CCSpriteFrame *frame3=CCS

mfc 在VC的两个对话框类中传递参数的三种方法

弄了好久,今天终于把在VC中的对话框类之间传递参数的问题解决了,很开心,记录如下: 1. 我所建立的工程是一个基于MFC对话框的应用程序,一共有三个对话框,第一个对话框为主对话框,所对应的类为CTMDDDlg类.在主对话框上我放置了一个标签页(Tab Control)控件,其实现的功能是当单击标签提示A时进入页面A,即对话框A(所对应的类为CDialogChild1),单击B时进入对话框B(CDialogChild2). 整个工程的框架已经设计好了,在对话框A和对话框B上放置了许多控件,现在我想