This is intended for new Android developers.
If you're looking to align elements to the top or bottom of your layout, look no further!
I have bolded the important parts below.
Basically, this layout utilizes RelativeLayout. You can align to the RelativeLayout using
android:layout_alignParentTop and layout_alignParentBottom. Then, you can align elements to that element's ID using android:layout_below.
Here is an example, with a Button at the top of the layout and a ListView taking up all the rest of the space.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/topcontrolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
>
<Button
android:id="@+id/Button"
android:text="@string/ShowRecent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<ListView
android:id="@+id/List"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topcontrolbar"
android:orientation="vertical"
/>
</RelativeLayout>
If you're looking to align elements to the top or bottom of your layout, look no further!
I have bolded the important parts below.
Basically, this layout utilizes RelativeLayout. You can align to the RelativeLayout using
android:layout_alignParentTop and layout_alignParentBottom. Then, you can align elements to that element's ID using android:layout_below.
Here is an example, with a Button at the top of the layout and a ListView taking up all the rest of the space.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/topcontrolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
>
<Button
android:id="@+id/Button"
android:text="@string/ShowRecent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<ListView
android:id="@+id/List"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topcontrolbar"
android:orientation="vertical"
/>
</RelativeLayout>