解决Android 4.4沉浸式状态栏一些小问题
来源:互联网 发布:mac 系统使用 编辑:程序博客网 时间:2024/04/29 00:33
看了别人的App,状态栏和标题栏一个颜色,感觉好看极了,于是研究了Android状态栏,因为自己手机是Android4.4,于是就查了一些资料。
就简单的几步就可以完成,首先在代码里实现:
写在onCreate里
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(true); // 自定义颜色 tintManager.setTintColor(Color.parseColor("#508aeb"));
以及用到的方法
private void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
这里要用到github上的开源项目SystemBarTint ,因为不用这个开源项目,你实现了这句
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
使得状态栏透明,而且标题栏会跑到状态栏上去,然后你设置
<item name="android:fitsSystemWindows">true</item>
之后虽然状态栏和标题栏位置固定好了,但是状态栏颜色变透明了。之后解决的办法就是参照开篇的代码,利用这个开源项目,导入module依赖就搞定了。
0 0
- 解决Android 4.4沉浸式状态栏一些小问题
- android 4.4状态栏沉浸
- Android 沉浸式状态栏
- android 沉浸式 状态栏
- android 沉浸式状态栏
- android沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- Android沉浸式状态栏
- android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- android沉浸式状态栏
- Android 沉浸式状态栏
- 关于 Eclipse hierarchy of the type is inconsistent错
- Mongo Index
- 微信小程序之『自定义toast』
- Android编程之SMS读取短信并保存到SQLite
- selector与shape
- 解决Android 4.4沉浸式状态栏一些小问题
- 二叉树的遍历方法
- 多渠道打包
- 解决Ubuntu14.04分辨率太高进不了系统
- 用sublime text3 快捷键创建一个html5
- Android必会小功能总结
- UVa816 Abbott的复仇
- javascript之innerText
- Android开发之监听或获取手机短信内容