I have a scrollable ListView with items (like in http://developer.android.com/resources/tutorials/views/hello-listview.html). I am using an ArrayAdapter
for the items and use it as a parameter in setListAdapter
. Now I would like to add a button at the bottom of the screen, which does not scroll with the list. Could someone give me some hints or post a code snippet how it could possibly be done?
If your activity extends ListActivity then you need something like this:
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:id="@android:id/list" android:layout_height="0dip" android:layout_width="match_parent" android:layout_weight="1" /> <Button android:id="@+id/btn" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
Notice that the listview has a layout_weight set to 1. That will keep the button fixed in its place at the bottom. Hope that helps. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With