title: Android: ListView, problem with rounded corners
body: <p>I have ListView with rounded corners implemented like bellow.</p>
  
  <pre><code>&lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/list"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="@drawable/list_bg"
      android:divider="#dbdbdb"
      android:dividerHeight="1sp"
      android:cacheColorHint="#00000000"
      android:descendantFocusability="afterDescendants"
      android:scrollbars="vertical"&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>where list_bg.xml is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle"&gt;
      &lt;solid android:color="#ffffff"/&gt;
      &lt;corners android:bottomLeftRadius="10dp"
              android:bottomRightRadius="10dp" 
              android:topLeftRadius="10dp"
              android:topRightRadius="10dp"
              /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>This give me rounded corners. 
  The problem is that each items are RelativeLayout with TextView on the left side and ImageButton on the right side. Both views have custom graphic on pressed, foucused and default state. Something like this.</p>
  
  <pre><code>+------------------------------------+
  |      TextView        | ImageButton |
  +------------------------------------+
  </code></pre>
  
  <p>The problem is that custom graphic cover ListView background and thus rounded corners on first and last item. Everything is okay when scrolling.</p>
  
  <p>I've written custom adapter and in getView method I set proper bg for items.</p>
  
  <pre><code>@Override
  public View getView(int position, View view, ViewGroup parent) {        
      ...
      if(position == 0) {
          mItemView.setBackgroundResource(R.drawable.cell_item_first_selector);
          mImgBtn.setBackgroundResource(R.drawable.cell_btn_first_selector);
      }
      else if (position == mData.size() -1) {
          mItemView.setBackgroundResource(R.drawable.cell_item_last_selector);
          mImgBtn.setBackgroundResource(R.drawable.cell_btn_last_selector);
      } 
      else {
          mItemView.setBackgroundResource(R.drawable.cell_item_def_selector);
          mImgBtn.setBackgroundResource(R.drawable.cell_btn_def_selector);
      }
      ... 
  }
  </code></pre>
  
  <p>It works, but I'm not sure that is good solution. Is there any other way to automatically round corners in Android Views, not just by setting background?</p>