Toolbar里的文本或者控件不能左对齐

原因:

Wiget.AppCompat.Toolbar的默认style指定了contentInsetStart属性,即内容插入只能在16dp处开始。

<style name="Base.Widget.AppCompat.Toolbar" parent="android:Widget">  
    <item name="titleTextAppearance">@style/TextAppearance.Widget.AppCompat.Toolbar.Title</item>  
    <item name="subtitleTextAppearance">@style/TextAppearance.Widget.AppCompat.Toolbar.Subtitle</item>  
    <item name="android:minHeight">?attr/actionBarSize</item>  
    <item name="titleMargins">4dp</item>  
    <item name="maxButtonHeight">56dp</item>  
    <item name="collapseIcon">?attr/homeAsUpIndicator</item>  
    <item name="collapseContentDescription">@string/abc_toolbar_collapse_description</item>  
    <item name="contentInsetStart">16dp</item>  
</style>

解决方法:

styles.xml中定义新的style继承自Wiget.AppCompat.Toolbar如下:

<style name="CustomToolbarStyle" parent="Widget.AppCompat.Toolbar">  
    <item name="contentInsetStart">0dp</item><!-- 设置该属性解决空白部分-->  
</style>

然后在你的style.xmlAppTheme里重写toolbarStyle属性.

<!-- Base application theme. “NoActionBar”隐藏原有的Actionbar 设置Toolbar -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    //.....
    <item name="toolbarStyle">@style/CustomToolbarStyle</item>
</style>
I Don't Want Your Money, I Want Aragaki Yui.