this solution provided by ban-geoengineering is very interesting ... The 3 dot icon sometimes doesn’t appear if you use the android namespace : showAsAction android: instead a custom namespace, for example:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/taskNotificationsBtn" app:showAsAction="always" android:icon="@drawable/tasks"/>
But the solution provided by ban-geoengineering helps me solve the problem of changing the direction of the ActionBar elements to fit the Arabic layout. I used the ActionBarRTLizer library, and the standard approach with android os 3dots causes some error when the menu item icons sometimes overlap (a very unpleasant situation), but this is a non-standard solution
<item android:id="@+id/empty" android:title="@string/options" android:orderInCategory="101" android:showAsAction="always" android:icon="@drawable/ic_action_overflow"> <menu> <item android:id="@+id/action_settings" android:icon="@android:drawable/ic_menu_preferences" android:showAsAction="ifRoom" android:title="@string/settings" /> <item android:id="@+id/action_help" android:icon="@android:drawable/ic_menu_help" android:showAsAction="ifRoom" android:title="@string/help" /> </menu> </item>
solved the problem and RTL works just fine! :)
This can also be useful if you want to handle hardware menu buttons:
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { // do stuff return true; } else { return super.onKeyUp(keyCode, event); } }
and add here: mMenuReference.performIdentifierAction (R.id.menu_0, 1);
to replace the submenu displayed as the overflow menu, depending, for example, on the current activity, you can use this solution:
public boolean onCreateOptionsMenu(Menu menu) {
Michał Ziobro
source share