-3

I want to center the ActionBar title text in my app...

I understand I need a custom layout to do this... So how do I do it?

I've tried following the instructions from here - How to center align the ActionBar title in Android? -

but it's not clear where to put the code. I tried my best to follow the steps, but my action bar stayed exactly the same.

Thanks.

Base API for my app is 16.

Community
  • 1
  • 1
Raphael
  • 85
  • 8
  • you need a custom layout to do that, because default layout of actionbar can't do it. :D – Eko Junaidi Salam Oct 14 '16 at 05:03
  • @EkoJunaidiSalam Oh, okay... My only concern with a custom layout is that I'd lose my `DrawerLayout` and hamburger button... How can I create a custom layout without losing these then? Thanks. – Raphael Oct 14 '16 at 22:10
  • how would you lose your `DrawerLayout` ? You can follow this [answer](http://stackoverflow.com/questions/12387345/how-to-center-align-the-actionbar-title-in-android) :D – Eko Junaidi Salam Oct 15 '16 at 00:19
  • @EkoJunaidiSalam That post doesn't have a clear answer... I've no idea where to put the code. I created a new xml and pasted the `getSupportActionBar()` codes in my `OnCreate`, but the action bar looks exactly the same. – Raphael Oct 15 '16 at 02:18
  • Please consider to edit your question bro, and let us know what have you tried so far. You can post your snippet code too. :D Please read [How To Ask a good question](http://stackoverflow.com/help/how-to-ask) :D – Eko Junaidi Salam Oct 15 '16 at 04:26
  • 1
    @EkoJunaidiSalam Yeah, I get it. Thanks... I'll update my post when I can. – Raphael Oct 15 '16 at 04:51

1 Answers1

0

ActionBar with Custom View will help you. It is clear and easy to follow.

EA Rashel
  • 167
  • 2
  • 9