Activity与AppCompatActivity去掉标题栏

2018-10-17 17:12:18

Activity与AppCompatActivity去掉标题栏

Activity去标题栏

1.代码中实现


requestWindowFeature(Window.FEATURE_NO_TITLE);

//这句代码必须写在setContentView()前面

1

2

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


<application android:icon="@drawable/icon"   

        android:label="@string/app_name"   

        android:theme="@android:style/Theme.NoTitleBar"> 


<!--或者只对某个activity设置-->

<activity android:name="xxxx.xxxxx.xxxx.activity"

            android:theme="@android:style/Theme.NoTitleBar"/>

1

2

3

4

5

6

7

3.在style.xml文件里定义


<?xml version="1.0" encoding="UTF-8" ?>  

<resources>  

    <style name="notitle">  

        <item name="android:windowNoTitle">true</item>  

    </style>   

</resources>

1

2

3

4

5

6

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


<application android:icon="@drawable/icon"   

        android:label="@string/app_name"   

        android:theme="@style/notitle"> 


<!--或者只对某个activity设置-->

<activity android:name="xxxx.xxxxx.xxxx.activity"

            android:theme="@style/notitle"/>

1

2

3

4

5

6

7

AppCompatActivity去标题栏

1.代码中实现,这里有两种方式


//方式一:这句代码必须写在setContentView()方法的后面

getSupportActionBar().hide();


//方式二:这句代码必须写在setContentView()方法的前面

supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

1

2

3

4

5

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


<application

   android:theme="@style/Theme.AppCompat.NoActionBar">


<!--或者只对某个activity设置-->

<activity android:name="xxxx.xxxxx.xxxx.activity"

            android:theme="@style/Theme.AppCompat.NoActionBar"/>

--------------------- 

作者:jiejingguo 

来源:CSDN 

原文:https://blog.csdn.net/jiejingguo/article/details/80133880?utm_source=copy 

版权声明:本文为博主原创文章,转载请附上博文链接!

  • 2019-04-25 15:40:16

    JS对象是否拥有某属性如何判断

    原型链上继承过来的属性无法通过hasOwnProperty检测到,返回false。 需注意的是,虽然in能检测到原型链的属性,但for in通常却不行。

  • 2019-04-30 11:23:36

    elasticsearch和analysis-ik的安装使用

    全文搜索和中文分词主要介绍了两组全文搜索加中文分词方案; TNTSearch+jieba-php这套组合对于博客这类的小项目基本够用了;

  • 2019-04-30 11:42:24

    php7+laravel+coreseek(sphinx)中文搜索初步实现(Linux)

    官网www.coreseek.cn已不能下载,所以需从网上找资源, 注意的一点是,笔者安装coreseek-3.2.14版本后,使用时提示client版本高于server版本的错误, php的sphinx扩展,为使用者,为client;coreseek是系统服务,为server

  • 2019-04-30 13:55:13

    浅谈mysql fulltext全文索引优缺点

    为什么会注意到mysql的fulltext? nima, 还是上次innodb转成tokudb引擎的事,这次alter修改表引擎的时候,提示percona tokudb是不支持fulltext索引的.