1

I am trying to create a toolbar that has text pinned to the left, text pinned to the right and a SeekBar in the middle that takes up the remaining space.

I have played around with layout and have not had any luck.

Here is what I have:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_bottom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:layout_alignParentBottom="true"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <TextView android:id="@+id/left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:text="Left Text"/>

    <SeekBar android:id="@+id/slider"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_toRightOf="@+id/left"
        android:layout_toLeftOf="@+id/right"
        android:max="999"
        android:progress="100"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"/>

    <TextView android:id="@+id/right"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="Right Text"/>

</android.support.v7.widget.Toolbar>

Cant seem to get the SeekBar to take up the rest of the space.

lostintranslation
  • 23,756
  • 50
  • 159
  • 262

1 Answers1

3

I just added a linearlayout and got it to work.

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar_bottom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="?attr/colorPrimary"
    android:minHeight="?android:attr/actionBarSize"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Left Text"/>

        <SeekBar
            android:id="@+id/slider"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:max="999"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            android:progress="999"/>

        <TextView
            android:id="@+id/right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Right Text"/>
    </LinearLayout>
</android.support.v7.widget.Toolbar>
Eugene H
  • 3,520
  • 3
  • 22
  • 39