Android options Menu horizontal divider
I'm having a problem while showing the options menu in a Samsung Galaxy phone, with Android 2.2. My menu has four items, and I arranged them in what I think is the default way:
<item android:id="@+id/feedback"
android:icon="@drawable/ic_menu_send"
android:title="@string/feedback" />
<item android:id="@+id/share"
android:icon="@drawable/ic_menu_share"
android:title="@string/share" />
<item android:id="@+id/sign_out"
android:icon="@drawable/ic_menu_close_clear_cancel"
android:title="@string/sign_out" />
<item android:id="@+id/preferences"
android:icon="@drawable/ic开发者_如何学编程_menu_preferences"
android:title="@string/preferences" />
On the corresponding activity, I'm inflating the menu this way:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.sr_menu, menu);
return true;
}
When the menu shows, I can't see the horizontal line that separates the two upper items from the lower ones. The grid appears as two adyacent columns, instead of four squares. In the emulator it seems to be working fine, but in the phone I'm having that issue.
Any ideas? Should I create a custom menu instead? I don't want to change any other attribute of the menu, just expect the default behavior.
Thanks in advance.
This is not an issue, different android flavors use different layouts, you can see that obvious in the apps menu "different devices have different menus and use different animations".
But if you want a consistent UX across all devices, you can achive that easily by combining a FrameLayout
with your current layout as its first frame , and a Relative Layout
as host for your menue buttons.
then you can implement onCreateOptionsMenue and make your menu visible.
and use onBackPressed
to Hide it MenuItem.setVisibility(View.GONE)
Hope that helps
Try making your menu title and icon items smaller. I've had problems with the layout of standard menus when the size of either of those is too large. Try just showing the titles first and then add each icon until the problem appears.
精彩评论