I have an existing app with a full screen viewer that uses the menu button to show options. I've set the android:targetSdkVersion to be 14 to have the entire app theme look like a native ICS APP.
The problem is that when setting the Activity style to be full screen, I don't have the menu button, and if I show the ActionBar, is takes app too much screen space just to display a menu.
Is there any way of keeping the regular menu button while in full screen on ICS?
I suppose there is no way to show only small part of action bar of ICS - at least it will look strange. The best way for you is create somewhere in your app "menu button". If you want to hide this button for phones with hardware menu button there is option to check SDK version:
android.os.Build.VERSION.SDK_INT
There is a way, if you're comfortable with hackiness and reflection. Daniel Lew mentions it in his blog. He notes, appropriately, that this really isn't meant to be used with production code. The Android developers may take away this ability in the future.
public static void addLegacyOverflowButton(Window window) {
if (window.peekDecorView() == null) {
throw new RuntimeException("Must call addLegacyOverflowButton() after setContentView()");
}
try {
window.addFlags(WindowManager.LayoutParams.class.getField("FLAG_NEEDS_MENU_KEY").getInt(null));
}
catch (NoSuchFieldException e) {
// Ignore since this field won't exist in most versions of Android
}
catch (IllegalAccessException e) {
Log.w(TAG, "Could not access FLAG_NEEDS_MENU_KEY in addLegacyOverflowButton()", e);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With