Is there any way to change the left margin of the Navigation icon and the right margin of the Action items in Toolbar
?
Asked
Active
Viewed 2.1k times
25

timemanx
- 4,493
- 6
- 34
- 43
1 Answers
50
I went through the Toolbar
source code to find a solution and it turned out to be pretty simple.
Toolbar uses two styles to style the toolbar and the navigation icon. Just had to override those styles with my own.
<style name="myToolbarNavigationButtonStyle" parent="@style/Widget.AppCompat.Toolbar.Button.Navigation">
<item name="android:minWidth">0dp</item>
<item name="android:padding">12dp</item>
<item name="android:scaleType">centerInside</item>
</style>
<style name="myToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
<item name="android:paddingRight">10dp</item>
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="toolbarStyle">@style/myToolbarStyle</item>
<item name="toolbarNavigationButtonStyle">@style/myToolbarNavigationButtonStyle</item>
</style>

timemanx
- 4,493
- 6
- 34
- 43
-
1Does anyone have a github repository they can point to that leverages this solution? I've tried numerous things at this point, including this solution. None of them seem to work for me. A full working project that could be shared would be very helpful. – Eric Schlenz Sep 16 '15 at 18:24
-
@EricSchlenz Ok. I'll create one. – timemanx Sep 17 '15 at 06:46
-
@ShubhadeepChaudhuri : This is not working for me. Do you have any idea? Please help me. – Sagar Panwala Oct 13 '15 at 18:08
-
This get's rid of my actionbar buttons and makes the single navigation button the whole width of my toolbar, any ideas? – Mullazman Feb 15 '16 at 11:36