Reputation: 29497
I have a ListActivity
that I'm trying to inflate a Button
from this layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/add_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/add_prop"
android:layout_alignParentBottom="true"
/>
</LinearLayout>
Using this code:
View footer = getLayoutInflater().inflate(R.layout.footer, null);
ListView listView = getListView();
listView.setTextFilterEnabled(true);
listView.addFooterView(footer, null, false);
The problem is that since the list isn't so big that takes the entire screen (at least I think this is why) the button stays at the end of the list instead of sticking to the bottom because of the android:layout_alignParentBottom="true"
property. What should I do to make it stick at the bottom?
Upvotes: 0
Views: 338
Reputation: 739
You have to create a new layout file with this code:
<?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" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/add_button" />
<Button
android:id="@+id/add_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/add_prop"
android:layout_alignParentBottom="true" />
</RelativeLayout >
Then set it as content view of your Activity
using setContentView()
Upvotes: 1