android沉浸式状态栏
来源:互联网 发布:gitbash windows 编辑:程序博客网 时间:2024/06/08 10:53
第一种方式
第一种方式,需要做下面三步设置
1、在values、values-v19、values-v21的style.xml都设置一个 Translucent System Bar 风格的Theme
values/style.xml
<style name="ImageTranslucentTheme" parent="AppTheme"> <!--在Android 4.4之前的版本上运行,直接跟随系统主题--></style>
values-v19/style.xml
<style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item></style>
values-v21/style.xml
<style name="ImageTranslucentTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item> <!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色--> <item name="android:statusBarColor">@android:color/transparent</item></style>
上面需要注意的地方是,无论你在哪个SDK版本的values目录下,设置了主题,都应该在最基本的values下设置一个同名的主题。这样才能确保你的app能够正常运行在 Android 4.4 以下的设备。否则,肯定会报找不到Theme的错误。
2、在AndroidManifest.xml中对指定Activity的theme进行设置
<activity android:name=".ui.ImageTranslucentBarActivity" android:label="@string/image_translucent_bar" android:theme="@style/ImageTranslucentTheme" />
3、在Activity的布局文件中设置背景图片,同时,需要把android:fitsSystemWindows设置为true
activity_image_translucent_bar.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@mipmap/env_bg" android:fitsSystemWindows="true"></RelativeLayout>
更多了解请参考:http://gold.xitu.io/entry/56b354e8c4c9710052e017aa/promote?utm_source=baidu&utm_medium=keyword&utm_content=android_statusbar&utm_campaign=q3_search
0 0
- Android 沉浸式状态栏
- android 沉浸式 状态栏
- android 沉浸式状态栏
- android沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- Android沉浸式状态栏
- android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- android沉浸式状态栏
- Android 沉浸式状态栏
- android沉浸式状态栏
- Android沉浸式状态栏
- <LeetCode> 题201:线段树的构造
- ZZULIOJ-1898-985的数字难题(水题)
- Android学习第八天---smali插桩
- zzulioj1897 985的红绿灯难题(数学)
- Scala之旅-class和object详解
- android沉浸式状态栏
- 聊聊HTTPS和SSL协议
- 【Arduino】1.5 串口的使用
- YII中遍历数组报错<非法字符串抵消“id”>
- 易懂之并查集
- 最小生成树+树上期望_____Abandoned country(hdu 5723 2016多校第一场)
- Volley Request的继承与异步映射JSON对象
- SG函数找规律练习-HDU3032- Nim or not Nim?
- 常见的几种排序方法