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

[common-ui] Add a new param "edgeToEdge" (true/false) to ActivitySettings #48

Open
dmitriy-chernysh opened this issue Dec 25, 2021 · 0 comments
Assignees

Comments

@dmitriy-chernysh
Copy link
Member

dmitriy-chernysh commented Dec 25, 2021

If edgeToEdge == true
set margins to 0

private fun applyWindowInsets(view: View) {
        ViewCompat.setOnApplyWindowInsetsListener(view) { _, windowInsets ->

            val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
            // Apply the insets as a margin to the view. Here the system is setting
            // only the bottom, left, and right dimensions, but apply whichever insets are
            // appropriate to your layout. You can also update the view padding
            // if that's more appropriate.
            view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
                leftMargin =0
                bottomMargin = 0
                rightMargin =0
                topMargin = 0
            }

            // Return CONSUMED if you don't want want the window insets to keep being
            // passed down to descendant views.
           WindowInsetsCompat.CONSUMED
        }
    }

Add this line to onCreate() if edge-to-edge == true

  WindowCompat.setDecorFitsSystemWindows(window, false)
@dmitriy-chernysh dmitriy-chernysh self-assigned this Dec 25, 2021
@dmitriy-chernysh dmitriy-chernysh changed the title Add a new param "edgeToEdge" (true/false) to ActivitySettings [common-ui] Add a new param "edgeToEdge" (true/false) to ActivitySettings Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant