Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make an indent from the status bar and the screen cutout? #1024

Closed
iFr0z opened this issue Dec 22, 2024 · 0 comments
Closed

how to make an indent from the status bar and the screen cutout? #1024

iFr0z opened this issue Dec 22, 2024 · 0 comments

Comments

@iFr0z
Copy link

iFr0z commented Dec 22, 2024

xFyxbd5i

inline fun View.snackBarTop(string: String, length: Int = LENGTH_LONG, f: Snackbar.() -> Unit) {
    val snackBarTop = make(this, string, length)
    val snackBarView = snackBarTop.view
    val params: LayoutParams = snackBarView.layoutParams as LayoutParams
    params.gravity = Gravity.TOP
    ViewCompat.setOnApplyWindowInsetsListener(snackBarView) { _, windowInsets ->
        val insets = windowInsets.getInsets(
            WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
        )
        snackBarView.translationY = insets.top.toFloat()
        WindowInsetsCompat.CONSUMED
    }
    snackBarView.layoutParams = params
    snackBarTop.f()
    snackBarTop.show()
}
@iFr0z iFr0z closed this as completed Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant