Adding bottom margin to ListView last element

Solution 1:

In your ListView, set a paddingBottom and clipToPadding="false".

  <ListView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="8dp"
      android:clipToPadding="false"
      android:scrollbarStyle="outsideOverlay"/>
  • This also works for RecyclerView.

  • Only use android:scrollbarStyle="outsideOverlay" if you want the scroll bar to not overflow into the padded area.

Solution 2:

add an empty footer in your list like this:

TextView empty = new TextView(this);
empty.setHeight(150);
listview.addFooterView(empty);

Solution 3:

you can also do it from code if you want, for example here I react to to EditText different situations:

   if(s.toString().length()>0)
   {
      contacts_lv.setClipToPadding(false);
      contacts_lv.setPadding(0,0,0,270*screenDensity);
   }
   else
   {
      contacts_lv.setClipToPadding(true);
      contacts_lv.setPadding(0,0,0,0);
   }

Solution 4:

Clocksmith's answer is the best and pretty clever. You can also create an empty footer view.