ListView with a button at the end of the list android studio

0

Good afternoon, I have a ListView that is bringing some data, it is working without problems. But at the bottom of the list, I need to put a button. This button should not be repeated, as it is happening. I placed the same inside the layout xml of the list.

    
asked by anonymous 06.09.2016 / 18:16

2 answers

0

You should use a Float Button and isolate your ListView in a Linear Layout, for example:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/ic_action_add" />

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true">

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@null" />

</LinearLayout>

The line:

android:layout_gravity="bottom|end"

You'll be responsible for leaving the Float Button in the lower right corner, once.

    
06.09.2016 / 18:48
0

You have to create a relative layout, and then you put the button down, then you add the list, but with the above tag, so first enter the button and then the list that has to be on top of the button

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:tools="http://schemas.android.com/tools">

    <Button
         android:id="@+id/button"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="bottom" 
         android:layout_alignParentBottom="true" />

     <ListView
         android:id="@+id/list"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:divider="@null"
         android:layout_above="@id/button" />

 </RelativeLayout>
    
06.09.2016 / 19:03