vien-dev
vien-dev

Reputation: 11

Why do we need another methods to goes edge-to-edge in Android while window.setFlags to FLAG_LAYOUT_NO_LIMITS always do the work

To ensure the modern look for my application, I want to make it goes edge-to-edge. Through some research I know that we can achieve it in 3 steps:

  1. Make the App's layout spreads all the screen. To do this with API 29, we set systemUiVisibility before the layout is inflated. From API 30, we must use window.setDecorFitsSystemWindows(false)
  2. Make the status bar and navigation bar transparent From API 29, we must set status bar and navigation bar's color to transparent.
  3. Handle insets.

The problem is, before I came up with the summary, I get some tips and tricks to use

window.setFlags(
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
        )

It works all the time! even with older API version, I think. And I don't even have to change the theme file. And in all the cases, I don't even have to change the translucent. So...why do we need to use many other methods while window.setFlags for FLAG_LAYOUT_NO_LIMITS works all the time?

I tried to make my app goes edge-to-edge using methods mentioned in Android API version 29 and 30. I tried the same with window.setFlags FLAG_LAYOUT_NO_LIMITS.

I expect a unified method that align with Android official site's documentation.

Upvotes: 1

Views: 254

Answers (1)

Ahmed Ashour
Ahmed Ashour

Reputation: 580

In case someone is still searching for this, using the:

window.setFlags(
        WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
        WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
    )

Results in problem to detect keyboard on Android 10 and below, meaning that the system can not detect that there is a keyboard open and that results in content of modal for example be below the keyboard when it is open, and whatever you do will not fix this until you remove the window flags.

Upvotes: 0

Related Questions