当前位置:网站首页>设置状态栏颜色
设置状态栏颜色
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);
边栏推荐
- LFM signal denoising, time-frequency analysis, filtering
- [技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
- What is the MySQL column to row function
- Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory
- leetcode2309. The best English letters with both upper and lower case (simple, weekly)
- 剑指 Offer 31. 栈的压入、弹出序列
- Open that kind of construction document
- Opencascade7.6 compilation
- MySQL constraints and multi table query example analysis
- Sword finger offer II 031 Least recently used cache
猜你喜欢

【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度

How to batch add background and transition effects to videos?

How to use redis ordered collection

Cesium dynamic diffusion point effect

Webgpu (I): basic concepts
![[question] - why is optical flow not good for static scenes](/img/8d/2cf6f582bc58cc2985f50e3f85f334.jpg)
[question] - why is optical flow not good for static scenes
![[graduation season] graduate seniors share how to make undergraduate more meaningful](/img/03/9adc44476e87b2499aa0ebb11cb247.png)
[graduation season] graduate seniors share how to make undergraduate more meaningful

RTL8189FS如何关闭Debug信息

leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)

【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
随机推荐
RTL8189FS如何关闭Debug信息
Leetcode face T10 (1-9) array, ByteDance interview sharing
STM32F103 - two circuit PWM control motor
Pytest testing framework
【毕业季】研究生学长分享怎样让本科更有意义
Redis有序集合如何使用
Sword finger offer 42 Maximum sum of continuous subarrays
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
MySQL约束与多表查询实例分析
Infix expression to suffix expression (computer) code
A quick understanding of analog electricity
[C #] use regular verification content
[reading notes] programmer training manual - practical learning is the most effective (project driven)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
Construction and maintenance of business websites [11]
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
Five skills of adding audio codec to embedded system
leetcode2312. Selling wood blocks (difficult, weekly race)
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
leetcode2309. The best English letters with both upper and lower case (simple, weekly)