I've tried assigning weights of course, but it appears that isn't supported by Toolbar.
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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With