Android透明顶栏(沉浸式)在android4.4上的实现
来源:互联网 发布:软件结构设计的作用 编辑:程序博客网 时间:2024/04/28 09:28
android的透明顶栏是在android5.0加入的新特性, 虽然其实在ios中早就有了.....:
在5.0中的实现方式很简单:
在style.xml中的application 的主题中添加colorPrimary,即可, 还可以设置更多的默认颜色来进行主题的搭配,当然这不是我今天要说的重点;
为了在android4.4及以上的设备上也有沉浸式的体验,其实我们只要加入下面的代码在Activity的OnCreat中就可以了:
public static void setTransparentStyle(Context context, int colorResourceID){//获取颜色int color = context.getResources().getColor(colorResourceID);//形成完整沉浸式的方法((Activity)context).getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);SystemBarTintManager tintManager = new SystemBarTintManager((Activity) context);tintManager.setStatusBarTintEnabled(true); // 设置一个颜色给系统栏 tintManager.setTintColor(color); // 设置一个状态栏资源 tintManager.setStatusBarTintColor(color);}
这段代码有一个依赖的类, 直接复制到自己的工程中引用即可:
<script src="https://code.csdn.net/snippets/984384.js"></script>
0 0
- Android透明顶栏(沉浸式)在android4.4上的实现
- android 实现透明的沉浸式状态栏
- Android 4.4 沉浸式透明状态栏与导航栏,android4.4
- Android 4.4 沉浸式透明状态栏与导航栏,android4.4
- Android 沉浸式状态栏的实现方法、状态栏透明
- Android 沉浸式状态栏的实现方法、状态栏透明。
- Android 沉浸式状态栏的实现方法、状态栏透明
- Android 沉浸式状态栏的实现方法、状态栏透明
- Android 沉浸式状态栏的实现方法、状态栏透明
- Android 沉浸式状态栏的实现方法、状态栏透明
- Android 沉浸式状态栏的实现方法、状态栏透明
- coordinatelayout android:fitsSystemWindows 沉浸式状态栏在android4.4 和 4.4以上版本的坑
- Android 沉浸式状态栏把布局顶到状态栏上
- Android4.4 全屏幕模式,沉浸模式 & 在应用内开启透明状态栏和透明虚拟按钮
- Android4.4 全屏幕模式,沉浸模式 & 在应用内开启透明状态栏和透明虚拟按钮
- 实现android4.4沉浸式标题栏
- android4.4~6.0以上沉浸式实现
- Android4.4以上实现沉浸式状态栏
- ZOJ 3885The Exchange of Items 最小费用最大流
- Perl 学习(九)
- 找新朋友
- Linux SSH远程文件/目录传输命令scp
- Nginx Wiki(已过时最新:http://nginx.org/en/docs/)
- Android透明顶栏(沉浸式)在android4.4上的实现
- Kafka 新版Producer Java版代码阅读
- 使用navicat的命令行模式创建修改表和存储过程
- 231 Power of Two
- Python 实现递归算法
- [LeedCode OJ]#260 Single Number III
- zjnu(1181)——石子合并
- UI -响应者链
- 扩展欧几里德算法详解