I want to implement a screen layout as shown below, with a Scrollview at the top of the screen, and a block of 2 buttons which are fixed at the bottom of the screen. I also want the buttons to occupy a fixed proportion of the screen width, and have used weights in a horizontal layout to achieve this.
The ScrollView rows are populated from a database table, and may contain too many rows to be displayed on a single screen. For this reason I only want the ScrollView to occupy a fixed proportion of the top of the screen, so that the buttons always appear at the bottom of the screen.
I tried adapting the solution here: Android ScrollView and buttons at bottom of the screen - substituting my own interface elements, but this resulted in the ScrollView occupying the whole screen, and the buttons not being visible at all. I suspect this is because the weights in my "layoutContainer" LinearLayout were conflicting with the design of the suggested solution.
My current code is below. This renders the ScrollView and Buttons fine until the Scrollview gets too large - when that happens the buttons disappear from the bottom of the screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical"
tools:context="com.itm.timer.ItemActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="top"
android:text="@string/activity_meal_item_textview1"
android:textSize="16sp"
android:textStyle="bold" />
<ScrollView
android:id="@+id/scrollViewRecords"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="75" >
<LinearLayout
android:id="@+id/linearLayoutRecords"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/layoutContainer"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_weight="2" >
</RelativeLayout>
<RelativeLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="20" >
<Button
android:id="@+id/btnMealPlan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/clipboard"
android:onClick="onClickMealPlan"
android:text="Show Meal Plan" />
<Button
android:id="@+id/btnStartTimer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btnMealPlan"
android:drawableLeft="@drawable/starttimer"
android:onClick="onClickStartTimer"
android:text="Set Reminders" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_weight="2" >
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Any ideas for how to achieve what I want, or how to simplify my design to achieve the aim of accommodating the ScrollView and Buttons in fixed positions on the screen?