title: Dialog Behavior is wearied. while adding gridview
body: <p>I want to show images in dialog with the help of grid View. it is working fine but i am having a little problem with opening of Dialog. as you can see in screenshot. As i open dialog it opns but very small.</p>
  <p><a href="https://i.stack.imgur.com/FESu8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FESu8.png" alt="enter image description here" /></a></p>
  <p>But after scrolling down up to 2 or 3 items it automatically switch to bigger size. I don't understand why?</p>
  <p><a href="https://i.stack.imgur.com/e6eOn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e6eOn.png" alt="enter image description here" /></a></p>
  <p><strong>What i have Tried so far</strong></p>
  <p>code for showing dialog</p>
  <pre><code>LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View layout = inflater.inflate(R.layout.image_select_layout, null);
          final GridView grid = (GridView) layout
                  .findViewById(R.id.select_gridview);
          final Dialog dialog = new Dialog(ArtFun.this);
          dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
          dialog.setContentView(grid);
          
          grid.setAdapter(new ImagesAdapter(ArtFun.this));
          grid.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View v,
                      int position, long id) {
              Toast.makeText(getApplicationContext(), &quot;position = &quot;+ position, 1).show();
                  
              }
          });
          dialog.show();
  </code></pre>
  <p>image_select_layout.xml file</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;GridView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; 
      android:id=&quot;@+id/select_gridview&quot;
      android:layout_width=&quot;fill_parent&quot; 
      android:layout_height=&quot;fill_parent&quot;      
      android:verticalSpacing=&quot;10dp&quot;
      android:horizontalSpacing=&quot;10dp&quot;       
      android:numColumns=&quot;auto_fit&quot;
      android:stretchMode=&quot;columnWidth&quot;    
      android:gravity=&quot;center&quot; 
      android:background=&quot;@drawable/imageselect_bg&quot;    
  /&gt;
  </code></pre>
  <p>My ImageAdapter is this</p>
  <pre><code>public class ImagesAdapter extends BaseAdapter {
  
      private LayoutInflater gridInflater;
      private final int BACKGROUND_IDS[] = new int[] { R.drawable.image_004,
              R.drawable.image_005, R.drawable.img, R.drawable.image_004,
              R.drawable.image_005, R.drawable.img};
      private ImageLoader imageLoader;
  
      public ImagesAdapter(Context context){
      
          gridInflater = LayoutInflater.from(context);
          imageLoader = ImageLoader.getInstance();
          imageLoader.init(ImageLoaderConfiguration.createDefault(context));
      }
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return BACKGROUND_IDS.length;
      }
  
      @Override
      public Object getItem(int position) {
          // TODO Auto-generated method stub
          return BACKGROUND_IDS[position];
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  
      @SuppressLint(&quot;InflateParams&quot;)
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          
          ViewHolder holder;
          if (convertView == null) {
              convertView = gridInflater.inflate(R.layout.image_adapter_layout, null);
              holder = new ViewHolder();
              holder.img = (ImageView) convertView.findViewById(R.id.adapter_view);
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
          
          @SuppressWarnings(&quot;deprecation&quot;)
          DisplayImageOptions option = new DisplayImageOptions.Builder()
          .showImageForEmptyUri(R.drawable.image_005)
          .showImageOnFail(R.drawable.image_005).cacheOnDisc(false)
          .cacheInMemory(false).displayer(new FadeInBitmapDisplayer(500))
          .build();
          
          String uri = &quot;drawable://&quot; + BACKGROUND_IDS[position];
          
          imageLoader.displayImage(uri, holder.img, option);
  
          return convertView;
      }
  
       static class ViewHolder {
              ImageView img;
          }
  }
  </code></pre>
  <p>Image_adapter_layout.xml file</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;ImageView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:id=&quot;@+id/adapter_view&quot;
      android:layout_width=&quot;100dip&quot;
      android:layout_height=&quot;100dip&quot;
      android:contentDescription=&quot;@string/app_name&quot;
      android:padding=&quot;0dp&quot;
      android:scaleType=&quot;fitCenter&quot; /&gt;
  </code></pre>
  <p><strong>What i want now</strong></p>
  <p>I want to show dialog every time like showing in 2nd screenshot. Thanks in advance.</p>