Mobile Development 11 min read

EdgeUtils: Android Edge‑to‑Edge UI Utility Library Guide

EdgeUtils is an Android library built on androidx.core that simplifies edge‑to‑edge immersive UI by providing easy‑to‑use APIs, integration steps, code examples, visual‑conflict resolutions, gesture handling, and bug‑fixes for status‑bar, navigation‑bar, and toolbar adaptations.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
EdgeUtils: Android Edge‑to‑Edge UI Utility Library Guide

EdgeUtils is an Android library based on androidx.core that wraps the edge‑to‑edge immersive solution, offering a set of convenient APIs for full‑screen layout handling.

Integration : Add the JitPack repository ( maven { url 'https://jitpack.io' } ) and the dependency ( implementation 'com.github.JailedBird:EdgeUtils:1.0.0' ) to your project.

Usage : Call edgeToEdge() in an Activity to extend the layout to the whole screen and make the status‑ and navigation‑bar backgrounds transparent. Control system‑bar icon colors with edgeSetSystemBarLight(true) for dark icons on light backgrounds or edgeSetSystemBarLight(false) for light icons on dark backgrounds.

A typical base activity can be written as:

abstract class BasePosActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        if (usingEdgeToEdgeTheme()) {
            defaultEdgeToEdge()
        } else {
            customThemeSetting()
        }
        super.onCreate(savedInstanceState)
    }
}

protected open fun defaultEdgeToEdge() {
    edgeToEdge(false)
    edgeSetSystemBarLight(true)
}

Visual conflict solutions :

Status‑bar adaptation: add a View with id="@+id/edge" and use heightToTopSystemWindowInsets() to set its height dynamically, or retrieve the height via edgeStatusBarHeight() inside a coroutine after the view is attached.

Toolbar adaptation: apply top padding equal to the status‑bar height, preferably by wrapping the Toolbar in a FrameLayout and setting the padding on the container.

Navigation‑bar adaptation: use paddingBottomSystemWindowInsets() or marginBottomSystemWindowInsets() which already handle different navigation‑bar modes (full‑screen, virtual bar, etc.).

Gesture conflict: replace WindowInsetsCompat.Type.systemBars() with WindowInsetsCompat.Type.systemGestures() in the applySystemWindowInsetsPadding helper when needed.

Bug & compatibility notes :

Hiding the status bar can cause a black background; fix it by setting window.statusBarColor = Color.TRANSPARENT and window.navigationBarColor = Color.TRANSPARENT after disabling decor fitting.

To remove the scrim on fully transparent navigation bars, set the color to #01000000 instead of fully transparent.

Do not attach multiple ApplyWindowInset listeners to the same view, as this may cause unexpected behavior.

The repository also includes three demo projects (navigation‑sample, navigation‑edge‑sample, immersion‑sample) that showcase common scenarios and how EdgeUtils resolves them.

References: Android WindowInsets documentation and related official articles.

mobile developmentUIAndroidKotlinlibraryEdge-to-Edge
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.