记录开源库 SystemBarTintManager 用法
来源:互联网 发布:jira软件 编辑:程序博客网 时间:2024/04/27 14:33
曾使用过一次设置透明状态栏的开源库,地址: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用法记录
- 测试基础知识整理
- mser场景文字检测及筛选
- Centos配置yum源
- 重置kafka的offset
- java 使用poi导出excel,可控制固定前2列固定标头排版,带统计数据格式的
- 记录开源库 SystemBarTintManager 用法
- 获取一个随机数
- Java字节码指令集的使用详细
- 三款免费实用的本地文件夹同步/备份软件推荐 (SyncToy/FreeFileSync/Compare Advance)
- swift3.0 CGFloat、String互相转化
- fragment生命周期及用处
- 【Git】之Git使用案例
- java 操作MySQL数据库(一)
- Virtual Machine串口调试:用命名管道在宿主机与虚拟机间建立起通信连接