I run my app on Tablet, which has both status bar (on top of screen) and navigation bar (on bottom of screen).
I use this code to make Activity
Full screen.
public void hideNavigationBar() {
final View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(setSystemUiVisibility());
}
public static int setSystemUiVisibility() {
return View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
Then when I touch a Button
, I want to show a PopupMenu
. The problem is: when PopupMenu
is shown, the status bar and navigation bar appear.
I tried to add this line:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
It works for the status bar. But the navigation bar still appears when show PopupMenu.
How can I keep full screen when show PopupMenu
?
EDIT: Here is the code where I show the PopupMenu
:
ImageView btnOpen = (ImageView) findViewById(R.id.image_view_open);
btnOpen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popupMenu = new PopupMenu(ActivityViewImage.this, v);
getMenuInflater().inflate(R.menu.context_menu_image, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
//do something
return true;
}
});
popupMenu.show();
}
});
getSupportActionBar().hide();
– Dispensatory