android 状态栏沉浸
来源:互联网 发布:拉拉热门交友软件 编辑:程序博客网 时间:2024/04/28 19:06
设置android状态栏颜色和toolbar颜色一致
1、导入jar包,我用的是systembartint-1.0.4.jar–>add as library
2、在主题文件style标签内加入属性:
<item name="android:windowTranslucentStatus">true</item>
3、在要设置沉浸模式的activity的布局文件中加入属性:
android:fitsSystemWindows="true"
4、在要设置沉浸模式的activity的onCreate()方法中加入代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; winParams.flags |= bits; win.setAttributes(winParams); SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(R.color.colorPrimary); }
检测当android版本在4.4以上就启用透明状态栏,设置与Toolbar一致的颜色。
效果图如下:
0 0
- android 透明状态栏,沉浸状态栏
- Android系统状态栏\沉浸状态栏
- Android 沉浸式状态栏
- android 沉浸式 状态栏
- android 沉浸式状态栏
- android沉浸式状态栏
- Android实现状态栏沉浸
- android 状态栏沉浸
- Android沉浸式状态栏
- android 4.4状态栏沉浸
- Android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- android沉浸(透明状态栏)
- Android沉浸式状态栏
- Android 沉浸式状态栏
- Android 沉浸状态栏
- Android沉浸式状态栏
- iOS开发 - UICollectionViewLayout 自定义布局
- CentOS6.6 装nginx
- django1.8 model (2): Field types
- django1.8 model (3): Meta options
- SQLServer中的数据库相互移植。
- android 状态栏沉浸
- linux命令(5)Ubuntu apt-get安装卸载命令
- 初次接触网页设计 用户注册界面的设计心得
- hash数组的一个简单应用
- 【财富人生】启蒙之旅01
- 30多年程序员生涯经验总结【转】
- 8-28
- android自定义时间选择器
- Linux____套接字选项