tags:

views:

52

answers:

1

In Android, when an alert appears, the background is dimmed. I would like a similar effect for when the menu is opened. I tried the following code, but it didn't work:

@Override
public boolean onMenuOpened(int featureId, Menu m) {
    boolean ret=super.onMenuOpened(featureId,m);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    return ret;
}

Does anyone know how to achieve this?

+1  A: 

Normally, you set this flag when you have a new activity that uses ThemeDialog - that way, the dialog is rendered with the previous activity still visible, and in case of FLAG_DIM_BEHIND, darkened.

FLAG_DIM_BEHIND means that your current activity will be visible and have normal brightness, and the previous activity that is still visible (assuming you're using ThemeDialog) will be darkened. I'm not sure if you can use this flag for your purposes.

EboMike