gitmyhub

ImmersionBar

Java ★ 11k updated 4y ago

android 4.4以上沉浸式状态栏和沉浸式导航栏管理,适配横竖屏切换、刘海屏、软键盘弹出等问题,可以修改状态栏字体颜色和导航栏图标颜色,以及不可修改字体颜色手机的适配,适用于Activity、Fragment、DialogFragment、Dialog,PopupWindow,一句代码轻松实现,以及对bar的其他设置,详见README。简书请参考:http://www.jianshu.com/p/2a884e211a62

An Android library that controls the status bar and navigation bar appearance in your app with a simple one-line API, handling edge cases like notched screens and soft keyboard conflicts automatically.

JavaKotlinAndroidsetup: easycomplexity 2/5

ImmersionBar is an Android library for controlling the status bar (the thin strip at the top of the screen showing time, battery level, and notifications) and the navigation bar (the row of buttons at the bottom for back, home, and recents). It targets Android version 4.4 and above.

When building Android apps, developers often want the app content to flow visually behind these system bars, or want the bar colors to match the app design. ImmersionBar provides a single setup API to configure these bars: you can set them to transparent, pick custom colors, control whether the text and icons inside them appear dark or light, and hide them entirely if needed.

The library handles a range of tricky situations that trip up basic Android code: switching between portrait and landscape orientation, notched screens (the camera cutout at the top, as seen on Huawei, Xiaomi, and others), soft keyboard pop-up conflicts where the keyboard covers input fields, and differences between device manufacturers. On phones where Android's standard tools do not allow changing text color in the status bar, the library adapts automatically.

It works with the main Android screen building blocks: Activity, Fragment, DialogFragment, Dialog, and PopupWindow. Adding it to a project takes one line in the build file, and the minimum working code is one line of Java or Kotlin. A Kotlin extension module is available for a more natural Kotlin style.

The library is at version 3.2.2, distributed via Maven Central, and comes with a downloadable demo app to see the effects on a real device.

Where it fits