当前位置:网站首页>设置状态栏颜色
设置状态栏颜色
2022-07-02 02:20:00 【Rannki】
导入依赖: implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
// 设置状态栏颜色为白色 ImmersionBar.with(this).statusBarColor(R.color.white) .fitsSystemWindows(true).init();
基本用法(满足日常沉浸式):ImmersionBar.with(this).init();
ImmersionBar.with(this)
.transparentStatusBar() //透明状态栏,不写默认透明色
.transparentNavigationBar() //透明导航栏,不写默认黑色(设置此方法,fullScreen()方法自动为true)
.transparentBar() //透明状态栏和导航栏,不写默认状态栏为透明色,导航栏为黑色(设置此方法,fullScreen()方法自动为true)
.statusBarColor(R.color.colorPrimary) //状态栏颜色,不写默认透明色
.navigationBarColor(R.color.colorPrimary) //导航栏颜色,不写默认黑色
.barColor(R.color.colorPrimary) //同时自定义状态栏和导航栏颜色,不写默认状态栏为透明色,导航栏为黑色
.statusBarAlpha(0.3f) //状态栏透明度,不写默认0.0f
.navigationBarAlpha(0.4f) //导航栏透明度,不写默认0.0F
.barAlpha(0.3f) //状态栏和导航栏透明度,不写默认0.0f
.statusBarDarkFont(true) //状态栏字体是深色,不写默认为亮色
.flymeOSStatusBarFontColor(R.color.btn3) //修改flyme OS状态栏字体颜色
.fullScreen(true) //有导航栏的情况下,activity全屏显示,也就是activity最下面被导航栏覆盖,不写默认非全屏
.hideBar(BarHide.FLAG_HIDE_BAR) //隐藏状态栏或导航栏或两者,不写默认不隐藏
.addViewSupportTransformColor(toolbar) //设置支持view变色,可以添加多个view,不指定颜色,默认和状态栏同色,还有两个重载方法
.titleBar(view) //解决状态栏和布局重叠问题,任选其一
.titleBarMarginTop(view) //解决状态栏和布局重叠问题,任选其一
.statusBarView(view) //解决状态栏和布局重叠问题,任选其一
.fitsSystemWindows(true) //解决状态栏和布局重叠问题,任选其一,默认为false,当为true时一定要指定statusBarColor(),不然状态栏为透明色
.supportActionBar(true) //支持ActionBar使用
.statusBarColorTransform(R.color.orange) //状态栏变色后的颜色
.navigationBarColorTransform(R.color.orange) //导航栏变色后的颜色
.barColorTransform(R.color.orange) //状态栏和导航栏变色后的颜色
.removeSupportView(toolbar) //移除指定view支持
.removeSupportAllView() //移除全部view支持
.navigationBarEnable(true) //是否可以修改导航栏颜色,默认为true
.navigationBarWithKitkatEnable(true) //是否可以修改安卓4.4和emui3.1手机导航栏颜色,默认为true
.fixMarginAtBottom(true) //已过时,当xml里使用android:fitsSystemWindows="true"属性时,解决4.4和emui3.1手机底部有时会出现多余空白的问题,默认为false,非必须
.addTag("tag") //给以上设置的参数打标记
.getTag("tag") //根据tag获得沉浸式参数
.reset() //重置所以沉浸式参数
.keyboardEnable(true) //解决软键盘与底部输入框冲突问题,默认为false,还有一个重载方法,可以指定软键盘mode
.init(); //必须调用方可沉浸式
如果想隐藏状态栏,则可以这样设置:
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
边栏推荐
- leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
- leetcode2309. 兼具大小写的最好英文字母(简单,周赛)
- How to turn off debug information in rtl8189fs
- [learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
- pytest 测试框架
- leetcode373. Find and minimum k-pair numbers (medium)
- Five skills of adding audio codec to embedded system
- CSDN article underlined, font color changed, picture centered, 1 second to understand
- Sword finger offer 31 Stack push in and pop-up sequence
- The wave of layoffs in big factories continues, but I, who was born in both non undergraduate schools, turned against the wind and entered Alibaba
猜你喜欢
How to build and use redis environment
[reading notes] programmer training manual - practical learning is the most effective (project driven)
[pit] how to understand "parameter fishing"
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
No programming code technology! Four step easy flower store applet
How to use redis ordered collection
Leetcode face T10 (1-9) array, ByteDance interview sharing
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview
Medical management system (C language course for freshmen)
随机推荐
剑指 Offer 29. 顺时针打印矩阵
mysql列转行函数指的是什么
leetcode373. Find and minimum k-pair numbers (medium)
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
MySQL constraints and multi table query example analysis
leetcode2305. 公平分发饼干(中等,周赛,状压dp)
Architecture evolution from MVC to DDD
【深度学习】infomap 人脸聚类 facecluster
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
DNS domain name resolution
Design and implementation of key value storage engine based on LSM tree
CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
leetcode2312. 卖木头块(困难,周赛)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
Opencascade7.6 compilation
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
Es interview questions
A quick understanding of analog electricity
How to hide the scroll bar of scroll view in uniapp
2022安全员-C证考试题及模拟考试