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-29 15:05:57

    php 数组分页 array_slice()函数用法

    今天用到一个函数,非常好用,分享给大家 array_slice() -从数组中取出一段 也就是说用这个函数可以和sql语句一样实现分页,原理是将查询出的数组,取出从指定下标开始到指定长度的数组

  • 2019-12-30 10:17:21

    router-link传递参数,query

    在vue-router中,有两大对象被挂载到了实例this; $route(只读、具备信息的对象); $router(具备功能的函数) 查询字符串: 去哪里 ? <router-link :to="{name:'detail',query:{id:1}}"> xxx </router-link>

  • 2019-12-30 16:48:41

    vue provide/inject详解和用法

    父子组件交互方式多种,props、vuex、 、 emit、localStorage还有就是这个provide/inject了。它适合层级比较深的组件,比如子,子孙,子孙后代的组件有好几个用到父组件的某个属性,就可以用到这个provide/inject,它可以避免写大量繁琐的传值代码 我这里为什么要使用它? 我一个知识库详情父组件中包含了大量的子组件,每个子组件都需要父组件的知识库ID,这时候我不想写大量props,就用到provide/inject进行传值了