mdehghani February 2016

How to remove padding from action bar logo?

I've managed to set a logo for action bar using these lines of code:

getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher);
getSupportActionBar().setDisplayShowTitleEnabled(false); //optional

but there is always some sort of padding at the right of the logo. Is there a way to eliminate it?

screenshot

Answers


Pztar February 2016

Use setContentInsetsAbsolute(int leftInset, int rightInset) on your toolbar

The values are in dp by default it's set at 16dp


Helix February 2016

My typical solution when I want to go above and beyond what the ActionBar is designed for is to hide the ActionBar completely using

getSupportActionBar().hide(); 

and instead implement a relative layout within the activity's layout file that follows the guidelines of an ActionBar as outlined by google HERE

This provides the flexibility to alter the appearance to whatever degree you'd like while maintaining the graphical appearance of Material Design.

Post Status

Asked in February 2016
Viewed 2,421 times
Voted 8
Answered 2 times

Search




Leave an answer