Android 多变的,有范的沉浸式状态栏(UltimateBar)
来源:互联网 发布:动漫抱枕淘宝店画师 编辑:程序博客网 时间:2024/05/27 10:43
UltimateBar
透明状态栏导航栏、沉浸式状态栏导航栏的终极解决方案
特点:
1.四种效果,自定义颜色的状态栏和导航栏,半透明状态栏和导航栏, 沉浸式状态栏和导航栏,隐藏状态栏和导航栏;
2.可以自定义状态栏和导航栏的颜色和透明度;
3.KITKAT(Android 4.4)和LOLLIPOP(Android 5.0)上显示效果高度统一。
使用方法:
首先添加依赖:
compile 'org.zackratos:ultimatebar:1.0.3'
1.自定义颜色的状态栏和导航栏
在 onCreate() 方法中:
UltimateBar ultimateBar = new UltimateBar(this);ultimateBar.setColorBar(ContextCompat.getColor(this, R.color.DeepSkyBlue));
如果需要设置不透明度:
UltimateBar ultimateBar = new UltimateBar(this);ultimateBar.setColorBar(ContextCompat.getColor(this, R.color.SpringGreen), 50);
2.半透明状态栏和导航栏
在 onCreate() 方法中:
UltimateBar ultimateBar = new UltimateBar(this);ultimateBar.setTransparentBar(Color.BLUE, 50);
3.沉浸式状态栏和导航栏:
在 onCreate() 方法中:
UltimateBar ultimateBar = new UltimateBar(this);ultimateBar.setImmersionBar();
4.隐藏状态栏和导航栏:
在 onWindowFocusChanged() 方法中:
@Overridepublic void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus) { UltimateBar ultimateBar = new UltimateBar(this); ultimateBar.setHintBar(); }}
5.在 DrawerLayout 中设置自定义颜色的状态栏和导航栏:
首先需要设置 DrawerLayout 下面的主局部中添加 android:fitsSystemWindows=”true”:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:orientation="vertical"> </LinearLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/SpringGreen" android:layout_gravity="left"/></android.support.v4.widget.DrawerLayout>
注意是 DrawerLayout 下面的主布局,DrawerLayout 本身和抽屉布局都不能添加。
然后在 onCreate() 方法中:
UltimateBar ultimateBar = new UltimateBar(this);ultimateBar.setColorBarForDrawer(ContextCompat.getColor(this, R.color.DeepSkyBlue));
如果需要设置不透明度:
UltimateBar ultimateBar = new UltimateBar(this);ultimateBar.setColorBarForDrawer(ContextCompat.getColor(this, R.color.DeepSkyBlue), 50);
好了,别人的我转载一下,有什么不会的仔细看楼,挺简单的。。。
阅读全文
1 0
- Android 多变的,有范的沉浸式状态栏(UltimateBar)
- Android之---沉浸式状态栏的错误理解(官方有沉浸模式的感念但是没有沉浸式状态栏的说法)
- android沉浸式状态栏(像iOS一样的状态栏)
- android沉浸式状态栏的实现
- Android沉浸式状态栏的开发
- Android沉浸式状态栏的实现
- android沉浸式状态栏的实现
- Android 状态栏沉浸式的实现
- Android 沉浸式状态栏的实现
- Android沉浸式状态栏SystemBarTint的使用方法
- Android 4.4 沉浸式状态栏的实现
- Android沉浸式状态栏的细节
- android 沉浸式状态栏的实现
- android沉浸式状态栏的问题解决
- Android 沉浸式状态栏的实现
- Android沉浸式状态栏SystemBarTint的使用方法
- Android沉浸式状态栏SystemBarTint的使用方法
- android状态栏标题栏的沉浸式模式
- 证角相等
- 有关二叉树的遍历问题非递归
- 每日一题(22)——malloc与free(三)
- 页面从输入 URL 到页面加载显示完成过程
- git安装及命令学习总结
- Android 多变的,有范的沉浸式状态栏(UltimateBar)
- JavaScript进阶:数组常用方法
- 几种光纤接口(ST,SC,LC,FC)
- Java中基于Scanner 编写的计算器小程序
- 扩展,背包问题(全中文)
- tornado IOLoop源码阅读
- E
- [第1节] Java NIO流-简介和概述
- 2017年7月编程语言排行榜