I am trying to use the following code to center the text in the ActionBar, but it aligns itself to the left.
How do you make it appear in the center?
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle("Canteen Home");
actionBar.setHomeButtonEnabled(true);
actionBar.setIcon(R.drawable.back);
To have a centered title in ABS (if you want to have this in the default
ActionBar, just remove the "support" in the method names), you could just do this:In your Activity, in your
onCreate()method:abs_layout:Now you should have an
Actionbarwith just a title. If you want to set a custom background, set it in the Layout above (but then don’t forget to setandroid:layout_height="match_parent").or with: