title: Adding bottom margin to ListView last element
body: <p>I need to add to add ListView with complicated items background: different for even/odd and rounded corners at the top and bottom. It looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/m6YY7.png" alt="ListView top"></p>
  
  <p>I have implemented all this stuff via level-list, but there is one more thing I want to do.
  Now the bottom item is near the bottom of the screen. It is better to add some space. </p>
  
  <p><img src="https://i.stack.imgur.com/mnl9p.png" alt="ListView bottom looks not good"></p>
  
  <p>I don't want to add bottom margin to ListView, I need margin only for last item.</p>
  
  <p>The ways I see to do this:</p>
  
  <h2>Footer</h2>
  
  <p>A kind of hack – add footer with empty TextView to ListView. But footers are quite unstable things, they usually disappear after notifyDataSetChanged and there is no way to get them back</p>
  
  <h2>Image with transparent pixels</h2>
  
  <p>I asked designer to add transparent pixels to bottom background resource. Unfortunately, in this case vertical centering is completely broken.
  For example, there is 9patch like this:</p>
  
  <p><img src="https://i.stack.imgur.com/bavem.png" alt="9patch"></p>
  
  <p>And layout like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
          &gt;
      &lt;!-- View with background with transparent pixels on bottom --&gt;
      &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
                    android:id="@+id/item"
                    android:background="@drawable/some_bgr"
                    android:padding="10dp"
              &gt;
          &lt;TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"
                    android:text="Title"
                    android:layout_gravity="center"
                    android:textSize="18sp"
                  /&gt;
          &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                    android:text="Detail"
                    android:layout_gravity="center"
                    android:textSize="18sp"
                  /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;!-- Just for marking place took by view --&gt;
      &lt;FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"
                   android:layout_below="@id/item"
                   android:background="#88ff55"
              /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The result:</p>
  
  <p><img src="https://i.stack.imgur.com/EI64G.png" alt="Result"></p>
  
  <p>As you see, centering is not working. Unfortunately.
  (BTW, if specify this 9patch as background for TextView, centering works good. If you know any article, explaining this, please let me know.)</p>
  
  <h2>Add bottom margin to last item in Adapter implementation</h2>
  
  <p>That should work, but for unknown reason I still can't get it work. 
  I don't like this way, because I don't like to modify dimensions in code.</p>
  
  <h2>So</h2>
  
  <p>There is already imaginary way – construct some XML drawable with particular bitmap and margin. According to drawables concept it should be possible, but I can't find implementation. May be somebody knows?</p>
  
  <p>Any other ideas?</p>