title: How to allow an app to adapt to different screen widths automatically
body: <p>I did a bit of digging into <a href="https://developer.android.com/training/multiscreen/screensizes" rel="nofollow noreferrer">this article</a>, but was not able to get any solution to work.</p>
  
  <p><strong>My problem:</strong>
  I have a header layout that is included in all my screens. And depending on the width of the screen, I want to show one of three different header layouts. Sidenote; my app only supports portrait mode.</p>
  
  <p>My layouts are:</p>
  
  <ul>
  <li>[Image] [Button][Text] [Button][Text] --> for big screens</li>
  <li>[Image] [Button][Text] [Button] --> for medium screens</li>
  <li>[Image] [Button] [Button] --> for small screens</li>
  </ul>
  
  <p>And they should be chosen automatically by the app depending on the screen width. I want to get around doing this programatically because I would need to do this pretty much in every activity, so would be nice if this could be done correct so that the system can handle it.</p>
  
  <p><strong>I tried (but didn't work):</strong></p>
  
  <ul>
  <li>Putting the three different layouts in 3 different folders called "layout", "layout-sw320dp", "layout-sw400dp"</li>
  <li>Putting the three different layouts in 3 different folders called "layout", "layout-xxhdpi", "layout-xxxhdpi"</li>
  </ul>
  
  <p>Thanks a lot for your answers in advance!</p>
  
  <p><strong>Edit:</strong>
  The layout looks actually a bit more complicated that described here. The actual layout is the following:</p>
  
  <pre><code>&lt;LinearLayout&gt;
     &lt;RelativeLayout&gt;
       &lt;ImageView /&gt;
       &lt;LinearLayout&gt;
          &lt;LinearLayout&gt;
             &lt;ImageView /&gt;
             &lt;TextView /&gt;
          &lt;/LinearLayout&gt;
          &lt;LinearLayout&gt;
             &lt;ImageView /&gt;
             &lt;TextView /&gt;
          &lt;/LinearLayout&gt;
       &lt;/LinearLayout&gt;
     &lt;/RelativeLayout&gt;
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Also the image inside the first ImageView is loaded from the internet and I don't know its size before it has been loaded.</p>