I\'m trying to center the icon in the android action bar. I\'m using a custom layout that has a button on the left side, an icon in the center and the menu options on the r
The previous answers doesn't work for me (on Android 4.4 devices), because the outer container view groups did not expand to the full with, so the container group and the centered inner logo was already left aligned in the title bar.
I found a layout that works with the regular action bar menu (on right side) and regardless of enabling the regular action bar logo and title (on left side). This example only centers an additional logo.
You have to enable the custom view by this
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowCustomEnabled(true);
View cView = getLayoutInflater().inflate(R.layout.actionbar, null);
actionBar.setCustomView(cView);
but not this method (it disables all other elements in action bar).
// actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);