Reputation: 564
I am adding a custom view in toolbar but it is not using full toolbar width it gives space from left side.
code snippet
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent">
</LinearLayout>
</android.support.v7.widget.Toolbar>
getting view from this code snippet
Can anyone please tell me Why it is not using full width of toolbar?
Upvotes: 2
Views: 2139
Reputation: 3043
Actually it is only happens on Android version Lollipop and above. To remove the padding, you can set the content inset to 0dp
Add these to your toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
app:contentInsetStartWithNavigation="0dp"
It has been reported as an issue here https://code.google.com/p/android/issues/detail?id=213826
Upvotes: 2
Reputation: 2872
Add these 4 attributes in your toolbar it should help you override that effect.
android:contentInsetStart="0dp"
android:contentInsetLeft="0dp" app:contentInsetLeft="0dp" app:contentInsetStart="0dp"
Do let me know if this was of any help.
Upvotes: 4