title: Equal sizes of Pictures GridView in Android
body: <p>I want to display 2 images in a Row in <code>GridView</code>. </p>
  
  <p>I have tried to get the screen size in different ways. For example:</p>
  
  <pre><code>final int h = getResources().getDisplayMetrics().densityDpi;
  
  and set size of the image..
  convertView.setLayoutParams(new GridView.LayoutParams(h, h));
  </code></pre>
  
  <p>But this is not sufficent. If screen is large, then 2 images look very small - like peanut, on a big screen. </p>
  
  <p>Can anyone guide me that for example. Device's screen size is 4 inches in Portrait and I can create 2 images of almost 2 inches each.</p>
  
  <p><img src="https://i.stack.imgur.com/zzsW9.png" alt="enter image description here"></p>
  
  <p>here is my gridview xml file</p>
  
  <pre><code>  &lt;GridView
          android:id="@+id/grid_view"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:alwaysDrawnWithCache="true"
          android:clipChildren="true"
          android:gravity="center_horizontal"
          android:horizontalSpacing="2dp"
          android:verticalSpacing="5dp"
          android:numColumns="auto_fit"
          android:padding="0dp"
          android:scrollingCache="true"
          android:smoothScrollbar="true"
          android:stretchMode="columnWidth"
           &gt;
      &lt;/GridView&gt;
  </code></pre>