You need to customize the action bar with a custom layout. how to change your code according to your needs
action = getActionBar();
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL
| Gravity.CENTER_VERTICAL);
View v = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.customlayout, null);
action.setCustomView(v, lp);
action.setDisplayShowCustomEnabled(true);
action.setDisplayHomeAsUpEnabled(true);
action.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
note : you need to create your own layout: R.layout.customlayout.
user2894435