Set RelativeLayout child to fill unused space

android, android-layout, android-relativelayout

Solution

Use the code provided below:

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

    <ImageView
        android:id="@+id/img1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:src="@drawable/stat_brightness_on" />

    <SeekBar
        android:id="@+id/brightnessSeekBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_toLeftOf="@id/img2"
        android:layout_toRightOf="@id/img1" />

    <ImageView
        android:id="@+id/img2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@drawable/stat_brightness_on" />

</RelativeLayout>

Problem

I have this layout: ``` <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/stat_brightness_off" android:layout_toLeftOf="@id/brightnessSeekBar" /> <SeekBar android:id="@+id/brightnessSeekBar" android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_height="wrap_content" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/brightnessSeekBar" android:src="@drawable/stat_brightness_on" /> </RelativeLayout> ``` I need the `SeekBar` to fill all the horizontal space, unused by `ImageView`'s (they are about 64*64 px). What should I do?

Original source