Popup menu exits Immersive Mode

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Popup menu exits Immersive Mode



I've set up my application to use Immersive Sticky Mode, but I also use some elements that are above the Activity context and that when the user interacts with them, the application exits Immersive Mode and the status bar is displayed again. These elements are a dialog box and a popup menu for a toolbar. I was able to prevent the status bar from appearing when the dialog was called through the following code inside my showDialog method:


dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);



However, I am not able to do the same with the popup menu. These are the methods of creating and selecting the menu:


@Override
public boolean onCreateOptionsMenu(Menu menu)
getMenuInflater().inflate(R.menu.menu_view, menu);

return true;


@Override
public boolean onOptionsItemSelected(MenuItem item)
int choosenId = item.getItemId();

switch (choosenId)
case R.id.btn1:
lblTitle.setText(R.string.btn1);

break;
case R.id.btn2:
lblTitle.setText(R.string.btn2);

break;
case R.id.btn3:
lblTitle.setText(R.string.btn3);

break;
case R.id.btn4:
lblTitle.setText(R.string.btn4);

break;

return super.onOptionsItemSelected(item);



And this is the xml of my toolbar:


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorBackgroundDarker"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize">

<Button android:id="@+id/btnBack"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:background="@mipmap/button_back_orange" />
</RelativeLayout>

<TextView android:id="@+id/lblTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textSize="22sp"
android:textColor="@color/white"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_gravity="center"/>

</android.support.v7.widget.Toolbar>



OBS: I'm already using these codes on my Activities:


protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tutorial);

View decorView = getWindow().getDecorView();

decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION


public void onWindowFocusChanged(boolean hasFocus)
super.onWindowFocusChanged(hasFocus);
View decorView = getWindow().getDecorView();
if (hasFocus)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
else
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);











By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard