I want to inflate some views but have a button at bottom of the view. I already know how to dynamically inflate views and then inflate the button below the other inflated views. However, when there are only a few inflated views (causing the combined view to take less space than an entire screen) the button does not rest at the bottom of the page as i would like. My idea is that i need to have the button aligned at the bottom of the relative layout by setting the button to: android:layout_alignParentBottom (when i try to do this though the app crashes)
here is a screenshot of what i have, followed by a screenshot of what i want, all the items you see are inflated onto a scrollview that is inside a relative layout. I think the problem is that the button is inflated onto the scrollview which is only as large at the items force it to be (unfortunately I'm too noob to know how to inflate onto a different part of the view)
the code for the image on the left is as follows (i dont have and errors for the view on the left): parentView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/blurybg"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_height="wrap_content"
android:id="@+id/scrollView1"
android:layout_width="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id= "@+id/parent_of_inflated_view_id">
</LinearLayout>
</ScrollView>
</RelativeLayout>
childButton (other views are similar to this)
<?xml version="1.0" encoding="utf-8"?>
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="30dp"
android:layout_width="fill_parent"
android:background="@drawable/done"
android:layout_alignBottom ="@layout/availablerestaurants"
/>
Java for creating the inflator and inflating the button. other inflated views are similar to this (i use the same inflator of course). I am adding the inflated button last to get it at the bottom of the view.
LayoutInflater theInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
LinearLayout linLayout = (LinearLayout)findViewById(R.id.parent_of_inflated_view_id);
Button doneButtonCurrentRest= (Button) theInflater.inflate(R.layout.done_button_availrest, null);
linLayout.addView(doneButtonCurrentRest);
Thanks for the help, Adam