So I've been testing various ways to make the button appears as I want it to and been failing.
I'm trying to meet the following requirements that I've set for myself: A. The button must be at the bottom of the screen (known screen size if that helps in an answer) if the listview doesn't contain too many items B. The listview must push the button off-screen if it reaches it (this part I've solved by adding the button as a footer to the listview)
My problem is solving the first part. By adding it as a footer, it appears smack in the middle of the screen when the list contains few items. So I need help figuring a way to make it stay at the bottom till the listview gets big enough and then get pushed further down by the listview.
Here's my layout code so far:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<Button
android:id="@+id/Remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove product(s)" />
</RelativeLayout>
Also, this is how i added the button so it's at the end of the listview:
LayoutInflater inflater = LayoutInflater.from(this);
View v = inflater.inflate(R.layout.shopping_cart_activity, null);
Button removeprod = (Button) v.findViewById(R.id.Remove);
getListView().addFooterView(v);
I've looked up various answers here on stackoverflow, like this one. Unfortunately none of the answers there were concrete enough to solve it for me, maybe an example would of been more useful (new to this). I've also tried adding to the button the following:
android:layout_alignParentBottom="true"
and it didn't work. I've tried having the button in the layout for the listadapter as well and let's just say it turned out in x number of buttons, where x = how big the list was.
Any thoughts are greatly appreciated, thanks in advance. If you want me to add more to the post, let me know and I will edit as soon as possible.