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.
You can use layout_weight exactly for that :
With this, you’ll have the bottom button have the basic height, and the fakeButton take up all the remaining space.
layout_height controls how the remaining space should be split between the different views. Default value is 0 (doesn’t take any extra space). If you put both buttons to the same height and a weight of 1.0, then each button will take up 50% of the space.