Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Toolbar navigation icon and options menu margin

Tags:

Is there any way to change the left margin of the Navigation icon and the right margin of the Action items in Toolbar?

like image 982
timemanx Avatar asked Nov 07 '14 19:11

timemanx


People also ask

What is widget Toolbar?

android.widget.Toolbar. A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts.


1 Answers

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> 
like image 158
timemanx Avatar answered Oct 11 '22 12:10

timemanx