Search code examples
androidandroid-actionbaractionbarsherlock

How to make home button hug the left side of the action bar


I'm using ActionBarSherlock and have set an icon using android:logo in my theme. I'd like for the icon to be flush with the left side of the screen, but it always has 6px of spacing (measured using the hierarchy viewer). I've highlighted in red the part of the icon that I can't get rid of. If I set DISPLAY_HOME_AS_UP for the action bar, then the up affordance is shown as in the second image with no additional spacing.

I assume the spacing is there to keep the icon in the same place regardless of whether the up arrow present. I'm never going to show the up arrow, so I rather have the icon flush on the left.

ActionBar

ActionBar with up affordance


Solution

  • You can set customView like this:

    actionBar.setCustomView(R.layout.customActionBarLayout)

    and create your own layout just as you like it