1

I would like to put a logo in the ActionBar not placed on it's left side but centered. I tried to use setCustomView() function and it works but the logo (generally any View I use) is centered inside available space between "home" button on the left and potential ActionItems on the right. It means that the position of my logo changes with the number of ActionItems. It's described here: ActionBar - custom view with centered ImageView, Action Items on sides

Does anyone has any idea how could I put logo always in the center of the screen? I suppose it would require some dirty trick since it seems to be a stupid idea for many reasons but I need to do it.

Community
  • 1
  • 1
Izydorr
  • 1,926
  • 3
  • 23
  • 40

2 Answers2

0

My understanding, from what I have read about ActionBar, is that you can't really control this using the native ActionBar object. It seems there is a lot that you can't customize with it. And this is on purpose to give the same look and feel across all applications. I'm sure someone will kindly correct me if I'm wrong.

My fix, needing a very customizable bar, was simply to create my own. I then added this to all of my Activities. To make it easier, I created a BaseActivity and BaseListActivity to extend from for all of my other Activities and ListActivities, respectively.

This allowed me to put all of the functionality into these BaseActivities for my custom action bar. Then I just had to <include> my custom layout for the action bar in each Activity. I hope this makes sense and can help.

codeMagic
  • 44,549
  • 13
  • 77
  • 93
0

you have already seen my ans : https://stackoverflow.com/a/16029214/1168654

if you want Logo in center with Multiple ActionItems then its not possible. read this

but you can do this with using put custom items in custom actionbar layout file(But action item will be fix or put all action in one using Actionbar Provider or using DropDown Navigation or any other way).

Community
  • 1
  • 1
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177