记录开源库 SystemBarTintManager 用法
来源:互联网 发布:黄河大侠知乎 编辑:程序博客网 时间:2024/04/27 14:39
曾使用过一次设置透明状态栏的开源库,地址:https://github.com/jgilfelt/SystemBarTint 部分手机未成功。在这记录搜寻到的另一份使用方式,目前手上的手机均通过。但是否完全可以用,还待有其他手机再测试。先记录代码如下:
- public void setStateBarColor(Activity activity) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- //5.0 全透明实现
- //getWindow.setStatusBarColor(Color.TRANSPARENT)
- Window window = activity.getWindow();
- window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
- window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
- window.setStatusBarColor(Color.TRANSPARENT);
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- //4.4 全透明状态栏
- activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
- }
- // 设置状态栏颜色
- ViewGroup contentLayout = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content);
- SystemBarTintManager systemBarTintManager = new SystemBarTintManager(activity);
- SystemBarTintManager.SystemBarConfig config = systemBarTintManager.getConfig();
- int actionBarHeight = config.getActionBarHeight();
- contentLayout.getChildAt(0).setPadding(0, getStatusBarHeight(activity) + actionBarHeight, 0, 0);
- if (mStatusBarColor == 0) {
- setupStatusBarView(activity, contentLayout, Color.parseColor("#cccccc"));
- } else {
- setupStatusBarView(activity, contentLayout, mStatusBarColor);
- }
- // 设置Activity layout的fitsSystemWindows
- View contentChild = contentLayout.getChildAt(0);
- contentChild.setFitsSystemWindows(true);//等同于在根布局设置android:fitsSystemWindows="true"
- }
阅读全文
0 0
- 记录开源库 SystemBarTintManager 用法
- 记录开源库 SystemBarTintManager 用法
- SystemBarTintManager.java
- Android开源库之沉浸式通知栏的简单实现(SystemBarTintManager)
- Android开源库之沉浸式通知栏的简单实现(SystemBarTintManager)
- 【Android】SystemBarTintManager沉侵式菜单栏
- android实现沉浸式之systembartintmanager
- oracle 用法记录1
- gdb x用法记录
- 记录一下 exists 用法
- 一些SWING用法记录
- Cscope 用法记录-1
- fancybox 用法记录
- freemarker用法记录
- git用法记录
- toString的用法记录
- C/C++ 用法记录
- aws用法记录
- leetcode 605. Can Place Flowers
- Readis安装
- iOS 多线程安全的数组MultiThreadSafeObject
- Genymotion模拟器
- 时间选择器
- 记录开源库 SystemBarTintManager 用法
- 认识传感器
- CXF 简单实例
- SQL删除使用别名问题
- jquery、js中String或Object与json、json数组的互转
- python3.6+django2.0+pycharm搭建Web开发环境
- MySql错误代码1045的解决方案
- Java双循环之break的用法
- Delphi编译开关=====转帖收藏