title: How to make responsive layout in android xml?
body: <p>i'm trying to create a simple layout which is contain images. Here is what i do for now</p>
  
  <pre><code>&lt;RelativeLayout
      android:layout_marginStart="2mm"
      android:layout_marginTop="20sp"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;
  
      &lt;ImageView
          android:id="@+id/myImage"
          android:layout_width="27mm"
          android:layout_height="30mm"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
           /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And here is the result in 2 device(s)</p>
  
  <p>In pixel 2 api</p>
  
  <p><a href="https://i.stack.imgur.com/AM4iK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AM4iK.png" alt="enter image description here"></a></p>
  
  <p>and here is is nexus 4</p>
  
  <p><a href="https://i.stack.imgur.com/IDEQe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IDEQe.png" alt="enter image description here"></a></p>
  
  <p>The images are inside RecyclerView. Here is how i set it up in my fragment</p>
  
  <pre><code>layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
  myListArrival.setLayoutManager(layoutManager);
  </code></pre>
  
  <p>as you can see in pixel 2 , there is almost half of next picture showing up instead up in nexus 4. <strong>Maybe</strong> it's a margin.</p>
  
  <p>Btw, i'm using android studio emulator</p>
  
  <p>I'm using MM because this <a href="http://www.mysamplecode.com/2011/06/android-units-of-measurements.html" rel="nofollow noreferrer">http://www.mysamplecode.com/2011/06/android-units-of-measurements.html</a>.</p>
  
  <p>So my question is, how can i make the image size and margin are same in two devices ? how can i achieve it ?</p>
  
  <p>An Update using DP.</p>
  
  <p>And now, i'm only showing 2 pictures now</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
  
      android:layout_marginTop="20sp"
      android:layout_marginStart="20dp"
      android:layout_marginEnd="10dp"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;
  
      &lt;ImageView
          android:id="@+id/myImage"
          android:layout_width="170dp"
          android:layout_height="170dp"
  
           /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>result </p>
  
  <p>Nexus 4</p>
  
  <p><a href="https://i.stack.imgur.com/9JGiW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9JGiW.png" alt="enter image description here"></a></p>
  
  <p>Pixel 2</p>
  
  <p><a href="https://i.stack.imgur.com/P7kou.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P7kou.png" alt="enter image description here"></a></p>