My application works in full screen mode. Below code to hide navigation bar.
public static void hideDefaultControls(@NonNull final Activity activity) {
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
final Window window = activity.getWindow();
if (window == null) {
return;
}
final View decorView = window.getDecorView();
if (decorView != null) {
int uiOptions = decorView.getSystemUiVisibility();
if (Build.VERSION.SDK_INT >= 14) {
uiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
if (Build.VERSION.SDK_INT >= 16) {
uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
}
if (Build.VERSION.SDK_INT >= 19) {
uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
decorView.setSystemUiVisibility(uiOptions);
}
}
android.widget.PopupMenu;
PopupMenu popupMenu = new PopupMenu(context, anchor);
//init code...
popupMenu.show();
I want have full screen mode while popup menu is showing. I'm trying to call hideDefaultControls()
method after popup shown, but controls is hiding only after popup hidden.
Because PopupMenu use new DecorView (PopupDecorView), try: