title: How to adapt images with CardView?
body: <p>I am creating an App Gallery using CardView as my widget, but I am facing a problem that the images in my gallery are ignoring the size that I want for them, so they are all overlapping instead of creating a margin for it.</p>
  
  <p>I am adapting the following Android Image Gallery:</p>
  
  <p><a href="https://medium.com/@moforemmanuel/android-simple-image-gallery-30c0f00abe64" rel="nofollow noreferrer">https://medium.com/@moforemmanuel/android-simple-image-gallery-30c0f00abe64</a></p>
  
  <p>I want something like that:</p>
  
  <p><a href="https://i.stack.imgur.com/wvL8N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wvL8N.png" alt="enter image description here"></a></p>
  
  <p>But running my code I get this result when I have more than one image:
  <a href="https://i.stack.imgur.com/rMfZv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rMfZv.png" alt="enter image description here"></a></p>
  
  <p>And the code that I have based myself on you can see below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="190dp"
      android:layout_height="190dp"&gt;
  
      &lt;androidx.cardview.widget.CardView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginTop="1dp"
          android:layout_marginLeft=".5dp"
          android:layout_marginRight=".5dp"
          android:layout_marginBottom=".5dp"
          app:cardCornerRadius="1dp"&gt;
  
          &lt;FrameLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;
  
              &lt;ImageView
                  android:id="@+id/image"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:scaleType="center"
                  tools:ignore="ContentDescription" /&gt;
  
          &lt;/FrameLayout&gt;
  
  
      &lt;/androidx.cardview.widget.CardView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What should I change in my code so that I can modify the images' size and still maintain a margin so that I will always have an adaptive layout?</p>
  
  <p>Many thanks!</p>
  
  <p>P.S.:
  I've tried what Dharmaraj suggested but then I got the following layout:
  <a href="https://i.stack.imgur.com/exyXM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/exyXM.png" alt="enter image description here"></a></p>
  
  <p>Changing <code>android:layout_width</code> and <code>android:layout_height</code> to <code>"200sp"</code>, it stills overlaps as you can see below:</p>
  
  <p><a href="https://i.stack.imgur.com/T4yDV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T4yDV.png" alt="enter image description here"></a></p>
  
  <p>To load the images I am using this two functions:
  <a href="https://i.stack.imgur.com/gYyO1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gYyO1.png" alt="enter image description here"></a></p>