title: Why are there extra pixels around my Android GridView?
body: <p>I have a GridView in my Android application that has a number of ImageViews in it. The space on my screen is limited and I want the images to take up as much of the available space as they can. Unfortunately, the GridView always leaves 5 pixels of empty screen space around the outside edge of the ImageViews (the space between ImageViews is set with horizontal/vertical spacing and behaves correctly). The empty space acts kind of like a margin around the ImageViews, but I can't get rid of it. Does anyone know what's causing this "border" and how I can get rid of it (or at least make it smaller)? Thanks.</p>
  
  <p>Update: I'm creating the ImageViews by inflating an .xml file in the getView() method of my Adapter class. Here's the xml I'm inflating:</p>
  
  <pre><code>&lt;ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#FF00FF" /&gt;
  </code></pre>
  
  <p>I defined the GridView in my layout xml file like this:</p>
  
  <pre><code>&lt;GridView
     android:id="@+id/mygrid"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_above="@+id/abutton"
     android:layout_marginBottom="8dp"
     android:numColumns="5" android:background="#FF0000"/&gt;
  </code></pre>
  
  <p>Here's a screen shot of the problem. The red area in my GridView. The purple areas are my ImageViews. The image being displayed is a simple blue rectangle with a transparent center. The image is 45x45 pixels (but is only 30x30 pixels in my app - I'll worry about that later). The red border around the purple is what I am trying to eliminate.</p>
  
  <p><img src="https://i.stack.imgur.com/6ZxDA.png" alt="alt text"></p>