I've tried assigning weights of course, but it appears that isn't supported by Toolbar.
Asked
Active
Viewed 2,972 times
2 Answers
9
You can use the following to get rid of left margin in the tool bar
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
So finally your code can be like this-
<android.support.v7.widget.Toolbar
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:layout_width="match_parent"
android:layout_height="48dp">
<TextView
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/background_floating_material_dark" />
</android.support.v7.widget.Toolbar>
Edit You can do in the code also as-
toolbar.setContentInsetsAbsolute(0,0);
Even you can modify it in style too-
<item name="toolbarStyle">@style/Widget.Toolbar</item>
<style name="Widget.Toolbar" parent="@style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">0dp</item>
</style>

Sanjeet A
- 5,171
- 3
- 23
- 40
1
You can put a LinearLayout inside your Toolbar. The LinearLayout allows you to set an orientation and, once you've done that, you can use layout_weight.
So it would be like:
<android.support.v7.widget.Toolbar
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:layout_width="match_parent"
android:layout_height="48dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/background_floating_material_dark"
android:layout_weight="1" />
</LinearLayout>
</android.support.v7.widget.Toolbar>

Ernestas Venckus
- 3
- 1
- 4

Chelsea Troy
- 11
- 1