title: GridView item overlaps when scrolling
body: <p>I have a problem with overlapping items in GridView. They are dynamically loaded by Universal Image Loader and problem is when some of them are not square. 
  There is no problem when scrolling up to down:
  <img src="https://i.stack.imgur.com/ayJtF.png" alt="enter image description here"></p>
  
  <p>There is a spacing. But when scrolling down to up:</p>
  
  <p><img src="https://i.stack.imgur.com/K17jt.png" alt="enter image description here"></p>
  
  <p>As you can see, items overlaps here.</p>
  
  <p>How can I fix it? Here is my Fragment:</p>
  
  <pre><code>import android.app.Fragment;
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.*;
  import com.nostra13.universalimageloader.core.DisplayImageOptions;
  import com.nostra13.universalimageloader.core.ImageLoader;
  import com.nostra13.universalimageloader.core.assist.FailReason;
  import com.nostra13.universalimageloader.core.assist.ImageScaleType;
  import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
  import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
  
  import java.util.List;
  
  
  public class WhatsHotFragment extends Fragment {
      public static final String TAG = WhatsHotFragment.class.getSimpleName();
  
      private TopPodcastsAdapter adapter = null;
      private GridView podcastsGridView = null;
      private ITunesPodcastService iTunesPodcastService = new ITunesPodcastService();
      private DisplayImageOptions options;
      private LayoutInflater inflater = null;
      private ImageLoader imageLoader = ImageLoader.getInstance();
  
  
      public WhatsHotFragment() {}
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          this.inflater = inflater;
          View rootView = inflater.inflate(R.layout.whats_hot_fragment, container, false);
          podcastsGridView = (GridView) rootView.findViewById(R.id.podcastsGridView);
  
          options = new DisplayImageOptions.Builder()
                  .showImageOnLoading(R.drawable.ic_stub)
                  .showImageForEmptyUri(R.drawable.ic_empty)
                  .showImageOnFail(R.drawable.ic_error)
  //                .imageScaleType(ImageScaleType.EXACTLY)
                  .cacheInMemory(true)
                  .cacheOnDisk(true)
                  .considerExifParams(true)
                  .bitmapConfig(Bitmap.Config.RGB_565)
                  .build();
  
          getActivity().setTitle(R.string.whats_hot);
  
          updateTopPodcasts();
  
          return rootView;
      }
  
  
      private void updateTopPodcasts() {
          new DownloadTopPodcastsTask().execute();
      }
  
  
      public class DownloadTopPodcastsTask extends AsyncTask&lt;String, Void, List&lt;Podcast&gt;&gt; {
  
          @Override
          protected List&lt;Podcast&gt; doInBackground(String... strings) {
              List&lt;String&gt; podcastIds = iTunesPodcastService.getTopPodcastsIds();
              List&lt;Podcast&gt; podcasts = iTunesPodcastService.getPodcastsForIds(podcastIds);
              return podcasts;
          }
  
          @Override
          protected void onPostExecute(List&lt;Podcast&gt; podcasts) {
              adapter = new TopPodcastsAdapter(getActivity(), podcasts);
              podcastsGridView.setAdapter(adapter);
          }
      }
  
      static class ViewHolder {
          TextView podcastPrimaryGenreView;
          ImageView podcastImageView;
          TextView podcastTitleView;
          TextView podcastArtistView;
      }
  
      public class TopPodcastsAdapter extends BaseAdapter {
          private Context context;
          private List&lt;Podcast&gt; podcasts;
  
          public TopPodcastsAdapter(Context context, List&lt;Podcast&gt; podcasts) {
              this.context = context;
              this.podcasts = podcasts;
          }
  
          @Override
          public int getCount() {
              return podcasts.size();
          }
  
          @Override
          public Object getItem(int position) {
              return null;
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              final ViewHolder holder;
              View view = convertView;
              if (view == null) {
                  view = inflater.inflate(R.layout.podcast_card_item, parent, false);
                  holder = new ViewHolder();
                  assert view != null;
                  holder.podcastPrimaryGenreView = (TextView) view.findViewById(R.id.podcastCardPrimaryGenre);
                  holder.podcastImageView = (ImageView) view.findViewById(R.id.podcastCardImage);
                  holder.podcastTitleView = (TextView) view.findViewById(R.id.podcastCardTitle);
                  holder.podcastTitleView.setSelected(true);
                  holder.podcastArtistView = (TextView) view.findViewById(R.id.podcastCardArtist);
                  holder.podcastArtistView.setSelected(true);
                  view.setTag(holder);
              }
              else {
                  holder = (ViewHolder) view.getTag();
              }
              holder.podcastPrimaryGenreView.setText(this.podcasts.get(position).getPrimaryGenreName().toUpperCase());
              holder.podcastTitleView.setText(this.podcasts.get(position).getTitle());
              holder.podcastArtistView.setText(this.podcasts.get(position).getArtistName());
  
              imageLoader.displayImage(this.podcasts.get(position).getArtworkUrl600(), holder.podcastImageView, options, new SimpleImageLoadingListener() {
                          @Override
                          public void onLoadingStarted(String imageUri, View view) {
  
                          }
  
                          @Override
                          public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
  
                          }
  
                          @Override
                          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
  
                          }
                      }, new ImageLoadingProgressListener() {
                          @Override
                          public void onProgressUpdate(String imageUri, View view, int current, int total) {
                          }
                      }
              );
  
              return view;
          }
      }
  }
  </code></pre>
  
  <p>Here is my fragment.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;GridView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/podcastsGridView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center"
      android:numColumns="2"
      android:stretchMode="columnWidth"
      android:background="@color/grid_background"
      android:verticalSpacing="8dip"
      android:horizontalSpacing="8dip"
      android:padding="8dip"
      android:clipToPadding="false"/&gt;
  </code></pre>
  
  <p>And here is my item.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/podcastCard"
      android:layout_width="fill_parent"
      android:layout_height="match_parent"
      android:background="@drawable/card_redborder"
      android:orientation="vertical"&gt;
  
      &lt;TextView
          android:id="@+id/podcastCardPrimaryGenre"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="4dp"
          style="@style/CardTextSecondary"/&gt;
  
      &lt;ImageView
          android:id="@+id/podcastCardImage"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:scaleType="centerInside"
          android:adjustViewBounds="true"/&gt;
  
      &lt;TextView
          android:id="@+id/podcastCardTitle"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="4dp"
          style="@style/CardTextPrimary"/&gt;
  
      &lt;TextView
          android:id="@+id/podcastCardArtist"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="4dp"
          style="@style/CardTextSecondary"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Please help.</p>