Android 沉浸式模式

来源:互联网 发布:头像源码 编辑:程序博客网 时间:2024/03/29 10:10

注意.沉浸式模式是Android4.0后出现的,所以在使用的时候注意这一点。

1.为保障每个页面都使用的是沉浸式状态栏,统一风格,所以我们需要创建Theme

2.在res目录下创建values-v19/style.xml

3.添加如下属性

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">    <item name="windowNoTitle">true</item>      <item name="android:windowIsTranslucent">true</item>    <item name="android:windowTranslucentStatus">true</item></style>

windowNoTitle:代表没有标题栏
windowIsTranslucent:让activity透明化

4.在application标签中指定该theme


5.如果你的view向上偏移,那么你需要在xml中添加以下属性

android:fitsSystemWindows="true"   android:clipToPadding="false"

6.运行

0 0
原创粉丝点击