迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:UltimateBarX开源软件地址:https://gitee.com/zackratos/UltimateBarX开源软件介绍:UltimateBarX一款方便的设置状态栏和导航栏的各种效果的框架 github 地址:UltimateBarX gitee 地址:UltimateBarX 详细介绍:这就是 github 上最好用的 Android 状态栏导航栏库
同类型框架对比
使用方法在根目录的 build.gradle 里面添加 allprojects { repositories { ... maven { url 'https://jitpack.io' } }} 在子目录的 build.gradle 中添加 dependencies { // release 版本 // 将 $lastVersion 替换成上图中的版本号 implementation 'com.gitee.zackratos:UltimateBarX:$lastVersion' // snapshot 版本 implementation 'com.gitee.zackratos:UltimateBarX:dev-SNAPSHOT'}
// 只需要设置状态栏,不需要设置导航栏statusBarOnly { // 布局是否侵入状态栏(true 不侵入,false 侵入) fitWindow = true // 状态栏背景颜色(色值) color = Color.RED // 状态栏背景颜色(资源 id) colorRes = R.color.deepSkyBlue // 状态栏背景 drawable drawableRes = R.drawable.bg_common // 以上三个设置背景的方法用一个即可,如多次设置,后面的会把前面的覆盖掉 // light模式:状态栏字体 true: 灰色,false: 白色 Android 6.0+ light = true // 低版本 light 模式不生效,重新设置状态栏背景 // 防止状态栏背景色跟字体颜色一致导致字体看不见 // lvl 系列方法仅在低版本(不支持 light 模式的版本)下开启 light 模式生效 lvlColor = Color.BLACK lvlColorRes = R.color.cyan lvlDrawableRes = R.drawable.bg_lvl // 以上三个 lvl 方法用一个即可,如多次设置,后面的会把前面的覆盖掉}// 设置状态栏statusBar { fitWindow = true // ...}// 设置导航栏navigationBar { fitWindow = true // ...} 这三个方法都可以在 使用 statusBarOnly { transparent()} 跟下面的写法效果是一样的 statusBarOnly { fitWindow = false color = Color.TRANSLUCENT} 使用 例如,先用下面的代码实现状态栏变红色,不侵入,非 light 模式 statusBarOnly { color = Color.RED fitWindow = true light = false} 然后需要设置 light 模式,其他效果保持不变,直接用下面的方法即可 getStatusBarOnly { light = true}
当布局可侵入状态栏或导航栏时,如果需要给某个 targetView.addStatusBarTopPadding()targetView.addNavigationBarBottomPadding()
UltimateBarX.statusBarOnly(this) .fitWindow(true) .colorRes(R.color.deepSkyBlue) .light(true) .lvlColorRes(R.color.cyan) .apply(); 如果项目中引入了 UltimateBarXKt.statusBarOnly(this, barConfig -> { barConfig.setFitWindow(true); barConfig.setColorRes(R.color.deepSkyBlue); barConfig.setLight(true); barConfig.setLvlColorRes(R.color.cyan); return null;}); 0.7.0 以下版本的使用方法见 INSTRUCTION.old ProGuard-keep class com.zackratos.ultimatebarx.ultimatebarx.** { *; }-keep public class * extends androidx.fragment.app.Fragment { *; } 截图
Change Log联系我在使用中遇到任何问题,欢迎加我微信交流 LicenseCopyright 2020 ZackratosLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. ![]() |
请发表评论