How to determinate edge-to-edge enabled?

128 views Asked by At

How to determine in my fragment that in activity enabled edge-to-edge with function WindowCompat.setDecorFitsSystemWindows(window, false)

Any ideas?

Is it possible to get the value of WindowCompat.setDecorFitsSystemWindows(window, false)?

1

There are 1 answers

1
Marcin Orlowski On

There's no public API to query this state. You might need to manage this state in your app, perhaps by setting a flag when you enable edge-to-edge and then checking that flag in your fragment instead?

Alternatively you might try to deduct that from system UI visibility flags:

val isEdgeToEdgeEnabled = activity?.window?.decorView?.systemUiVisibility?.and(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0

But that would require use of reflection which can be risky because it might not work across different Android versions or devices and can break in future Android updates, so I do not recommend going that way if use of own flag suffices.