With Android's Multi-Window support, how do I detect if the status bar is visible? For instance, when in portrait orientation, the status bar might be visible if I'm the top app, but won't be visible when I'm the bottom app. Right now, my views are funny when on the bottom because I make space for the status bar that isn't there anymore.
Android Multi-Window Support : Detecting if status bar is visible?
Asked Answered
Assuming you mean the system UI bar, ie the status bar do this:
View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.
} else {
// TODO: The system bars are NOT visible. Make any desired
// adjustments to your UI, such as hiding the action bar or
// other navigational controls.
}
}
});
That is directly from the docs: https://developer.android.com/training/system-ui/visibility.html
Did you test this in multi-window environment? Seems out of context to me. I don't see how this helps OP determining by how much they need to offset content. –
Ruelle
ahem its right form the Google docs..it has already been tested by in fact Google –
Littman
The system ui visibility doesn't change when in multi-window mode. I get the same response whether fullscreen or in multi-window mode. –
Xerosere
@FredGrott Ahem, that post has been there at least since KitKat and the code does exactly what it looks like: report fullscreen layout. It does not provide any information about system insets which is what OP is asking for. –
Ruelle
© 2022 - 2024 — McMap. All rights reserved.
I don’t want to
- I didn’t want either. But this way I was able to update to N gracefully. These kind of recommendations are to be followed, or you’ll find your app messed up sooner or later, due to new APIs, new manufacturers, new devices with unpredictable insets. – Aliunde