Sunday, 5 June 2022

Android Spinner: How to keep status bar hidden in full screen?

I use this code to to hide the navigation bar:

View root = findViewById(android.R.id.content);
root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);     
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

But when a Spinner is touched, the status bar is shown on top of the screen.

This solution seems to work when android:spinnerMode="dropdown"

Field listPopupField = Spinner.class.getDeclaredField("mPopup");
listPopupField.setAccessible(true);
Object listPopup = listPopupField.get(spinner);
if (listPopup instanceof ListPopupWindow) {
    Field popupField = ListPopupWindow.class.getDeclaredField("mPopup");
    popupField.setAccessible(true);
    Object popup = popupField.get((ListPopupWindow) listPopup);
    if (popup instanceof PopupWindow) {
        ((PopupWindow) popup).setFocusable(false);
    }
}

Is there a solution for android:spinnerMode="dialog" ?



from Android Spinner: How to keep status bar hidden in full screen?

No comments:

Post a Comment