Q: Android: positioning priorities I have this simple piece of code in my app:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:baselineAligned="false"
    android:gravity="fill_horizontal"
    android:orientation="horizontal" >

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

        <ProgressBar
            android:id="@+id/elapsedTimeBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/elapsedTimeText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/time_mockup"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>

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

        <Button
            android:id="@+id/next"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:onClick="onNextClick"
            android:text="@string/next" />

    </LinearLayout>
</LinearLayout>


I want to achieve situation where button is on the right side of ProgressBar and ProgressBar fills whole spave left by Button.
I supposed code above will handle this, but in my case ProgressBar is streched and push out from canvas whole LinearLayout with Button . Can i do somehow that button (or layout with button) is a point of reference and "positioner" starts make order from it?

A: Change the width to "wrap_content" on the progressbar?
read more here:
http://ritald.blogspot.com/2013/05/lesson-6-android-wrapcontent-and.html

A: I figured it out:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:baselineAligned="false"
    android:gravity="fill_horizontal"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

        <ProgressBar
            android:id="@+id/elapsedTimeBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/elapsedTimeText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/time_mockup"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>

    <LinearLayout
            android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <Button
            android:id="@+id/next"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:onClick="onNextClick"
            android:text="@string/next" />
    </LinearLayout>
</LinearLayout>


It means Layout should be wrapped around button and layout with bar should have
android:layout_weight="1"

I dont know why this mechanism is such not intuitive, but it works.
