mardi 19 mai 2015

Seekbar in toolbar that takes up remaining space

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.

Aucun commentaire:

Enregistrer un commentaire