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-12-03 15:50:00

    html5 audio stop功能

    html5并没有提供停止功能,我们需要通过其他方式来实现这个问题,下面我们来看下神仙般的操作。

  • 2019-12-03 16:33:49

    hapi,nuxtjs跨域请求

    简单请求 与 预检请求,Fetch 与 CORS 的一个有趣的特性是,可以基于 HTTP cookies 和 HTTP 认证信息发送身份凭证。一般而言,对于跨域 XMLHttpRequest 或 Fetch 请求,浏览器不会发送身份凭证信息。如果要发送凭证信息,需要设置 XMLHttpRequest 的某个特殊标志位。

  • 2019-12-03 16:36:03

    跨域资源共享 CORS 详解

    阮一峰大哥的文章写的不错,推荐,也推荐他的整个王章,大家可以去看一下啊。

  • 2019-12-03 16:37:01

    去除options,减少options的访问

    因为跨域请求,浏览器可能(后面讲)会发送一次options请求,如果处理不好,跨域还是会gg的。 之前很少涉及跨域,涉及也是简单请求(下面阮老师文章中区别热简单请求和复杂请求),所以基本不会很少关注options。后面就遇到坑了,下面讲讲注意点。