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 

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

  • 2021-05-25 13:10:49

    npm 多个不同版本的依赖

    提起 npm,大家第一个想到的应该就是 npm install 了,但是 npm install 之后生成的 node_modules 大家有观察过吗?package-lock.json 文件的作用大家知道吗?除了 dependencies 和 devDependencies,其他的依赖有什么作用呢?接下来,本文将针对 npm 中的你可能忽略的细节和大家分享一些经验 。