I create an overflow menu using onCreateOptionsMenu, but the menu is positioned almost completely off the screen. I have tried setting android:anyDensity="true"
explicitly (as suggested in Action bar menu shows off screen), but that did not solve the problem for me. I also do not want to follow the suggestion of using an old theme (as in ICS - menu item text cut off?).
Screenshot (the right-hand side of the image is the physical screen border; the image was cut off on the left by me):
The XML is
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_about" android:title="About" android:icon="@android:drawable/ic_menu_info_details" /> <item android:id="@+id/menu_reset" android:title="Reset image" android:icon="@android:drawable/ic_menu_revert" /> <item android:id="@+id/menu_share" android:title="Share" android:icon="@android:drawable/ic_menu_share" android:showAsAction="ifRoom" /> <item android:id="@+id/menu_facebook_logout" android:title="FB logout" android:icon="@drawable/fbook" showAsAction="ifRoom" /> <item android:id="@+id/menu_save" android:title="Save" android:icon="@android:drawable/ic_menu_save" android:showAsAction="ifRoom" /> <item android:id="@+id/menu_exit" android:title="Exit" android:icon="@android:drawable/ic_menu_close_clear_cancel" /> </menu>
What am I doing wrong?
It turned out that I still had a
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
in my code, to avoid a bug in earlier Android versions (see Title bar apeared again after coming back in my application).
Removing this (it is no longer necessary in ice-cream-sandwich; have not yet tried other versions) made the overflow menu appear correctly.