How do you make a view fill the space available to it?

Viewed 5351

I know it must be an easy question... I just don't know how to fix it.

So (Just an example),

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:orientation="vertical">
    <Button     android:id="@+id/fakeButton"
                android:layout_height="match_parent"
                android:layout_width="match_parent"/>
    <Button     android:id="@+id/saveSearch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/saveSearch"/>
</LinearLayout>

This wouldn't work - the first button would make the 2nd invisible. Weights would make it all a percentage game which isn't what I want.

Am I being thick?

EDIT: I didn't know it, but it seem's the order is important (from answers). Loading a layout is iterative rather than holistic. You can make the first element a fixed height and the rest of the elements will fill what's left. BUT what I need is to make the final element a fixed height.

5 Answers
Related