title: Android - ImageView - Multiple Screen Support - Set height/width as dp or match_parent/wrap_content?
body: <p>I am currently trying to adjust my Android App so it will look and feel similar on multiple screens/devices.</p>
  
  <p>I know by now that a major part in this is to provide multiple image sizes for every image file according to the x1, x1.5, x2, x3, x4 ratios for mdpi, hdpi, xhpi, xxhdpi and xxxhdpi respectively, and I have finished doing so today.</p>
  
  <p>After doing this, I have defined <code>Density independent Pixel</code> dimensions in the @dimen.xml values resource that correspond with the actual image sizes in pixels of the MDPI resources. Subsequently, i have set the imageviews in question's <code>layout_width</code> and <code>layout_height</code> to this dimension.</p>
  
  <p>I am currently at a loss, however, as to why my application still looks significantly different on an MDPI emulator than it does on an HDPI emulator. To highlight what I mean, I'll provide the following screenshot showing the HDPI and MPDI emulator next to one another (left is HDPI (<code>4" WVGA Nexus S</code>) and right is MDPI (<code>5.4" FWVGA</code>)). I want both of them to look like the MPDI version, but what I've done so far apparently isn't working.</p>
  
  <p><img src="https://i.stack.imgur.com/yy8kR.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/RUMkP.png" alt="enter image description here"></p>
  
  <p>I have three theories of my own as to why this is not working the way I intend it to:</p>
  
  <p><strong>1.</strong> I am not supposed to set ImageView <code>layout_width</code> and <code>layout_height</code> to a dp value, but rather <code>match_parent</code> or <code>wrap_content</code> (?) (and change the structure of my .xml layouts in the process).  </p>
  
  <p><strong>2.</strong> I am not only supposed to define multiple drawable resources, but also multiple layout resources for different screen sizes (?). </p>
  
  <p><strong>3.</strong> I have misunderstood the entire idea behind how this is supposed to work (?).</p>
  
  <p>I will also give you an example of one of the list items that can be seen in the first screenshot (<code>@drawable/phone_speed_icon</code> is a <code>64 x64</code> pixel resource in MPDI and a <code>96x96</code> resource in HDPI, and <code>@dimen/icon_attribute_size</code> is <code>64dp</code>):</p>
  
  <pre><code>        &lt;LinearLayout
              android:id="@+id/llSpeed_PreSession"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              android:paddingBottom="10dp"
              android:paddingEnd="20dp"
              android:paddingStart="20dp"
              android:weightSum="100"&gt;
  
              &lt;LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="@dimen/icon_attribute_size"
                  android:layout_weight="20"
                  android:weightSum="100"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_weight="70"
                      android:gravity="center"
                      android:orientation="vertical"&gt;
  
  
                      &lt;ImageView
                          android:layout_width="@dimen/icon_attribute_size"
                          android:layout_height="@dimen/icon_attribute_size"
                          android:src="@drawable/phone_speed_icon" /&gt;
  
                  &lt;/LinearLayout&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_weight="30"
                      android:gravity="center_vertical"
                      android:paddingStart="10dp"
                      android:text="Speed"
                      android:textAppearance="@android:style/TextAppearance.Large"
                      android:textColor="#878787"
                      android:textStyle="bold" /&gt;
  
              &lt;/LinearLayout&gt;
  
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_weight="80"
                  android:gravity="center"&gt;
  
                  &lt;android.support.v7.widget.SwitchCompat
                      android:id="@+id/swSpeed_PreSession"
                      android:layout_width="wrap_content"
                      android:layout_height="match_parent" /&gt;
              &lt;/LinearLayout&gt;
  
          &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>In the end, I have four questions that I'd like answered:</p>
  
  <p><strong>1.</strong> How do I make the list items in screenshot 1 look the same on MDPI devices as HDPI devices? Does this have anything to do with one of the three theories I mentioned earlier?    </p>
  
  <p><strong>2.</strong> Why is the header text ("What do you want to measure?") wrapped on one device, but not on the other? They use the <code>sp</code> unit (via <code>android:style/TextApperance.TextApperance.Large</code>)?  </p>
  
  <p><strong>3.</strong> Shouldn't everything be more spaced out on an HDPI device (if anything) rather than less spaced out? The HDPI emulator looks as if it "has got way less pixels available", if you can understand what I'm saying even a little.  </p>
  
  <p><strong>4.</strong> How do I make the Fragments on the second screenshot look the same? Or should i not even want this, because the HDPI is (for some reason) physically smaller, which is why the layout is less spread out?</p>
  
  <p>Anyway, I have been at this all day and the more I read the more thouroughly confused I get, so any help is greatly appreciated!</p>