0

I added an option menu in my app.

I want activity's whole background appear dark when menu key is touched so the user can see option menu well.(like when a dialog is displayed)

Should I use animation to do this or is there any other way?

soonoo
  • 867
  • 1
  • 10
  • 35

1 Answers1

0

As you're using OptionMenu, you could do:

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.your_option_menu:         
        mRootLayout.setAlpha(0.5f);
        break;

    default:
        break;
    }

    return super.onOptionsItemSelected(item);
}

mRootLayout would be the root layout from the xml you set the view in your activity. Just use findViewById to set it.

After you select a final option in your menu, make sure to return the alpha property of the root layout to 1.

vinitius
  • 3,212
  • 2
  • 17
  • 22