title: Scale background image to wrap content of layout
body: <p>I have a layout that contains some text fields and has a background image that's displayed at the top of my activity.  I'd like the background image to scale to wrap the content (don't care about aspect ratio).  However, the image is larger than content, so the layout instead wraps the background image.  Here's my original code:</p>
  
  <pre><code>&lt;RelativeLayout 
      android:layout_width="fill_parent"
      android:id="@+id/HeaderList" 
      android:layout_gravity="top"
      android:layout_height="wrap_content" 
      android:background="@drawable/header"&gt;
      &lt;TextView 
          android:layout_height="wrap_content"
          android:layout_width="wrap_content" 
          android:id="@+id/NameText"
          android:text="Jhn Doe" 
          android:textColor="#FFFFFF"
          android:textSize="30sp" 
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true" 
          android:paddingLeft="4dp"
          android:paddingTop="4dp" 
      /&gt;
      &lt;TextView 
          android:layout_height="wrap_content"
          android:layout_width="wrap_content" 
          android:textColor="#FFFFFF"
          android:layout_alignParentLeft="true"
          android:id="@+id/HoursText"
          android:text="170 hours" 
          android:textSize="23sp"
          android:layout_below="@+id/NameText" 
          android:paddingLeft="4dp" 
      /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>After searching through some other questions, I found these two:</p>
  
  <p><a href="https://stackoverflow.com/questions/4312133/how-to-wrap-content-views-rather-than-background-drawable">How to wrap content views rather than background drawable?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1400782/android-scale-a-drawable-or-background-image">Scale a Drawable or background image?</a></p>
  
  <p>Based on this, I created a FrameLayout w/ an ImageView showing the background.  Unfortunately, I still can't get it to work.  I want the height of the background image to shrink/expand w/ the size of the text views, but with the FrameLayout, the ImageView fits to the size of it's parent, and I can't find a way to make the parent fit to the size the text view layout.  Here's my updated code:</p>
  
  <pre><code>&lt;FrameLayout 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" &gt;
  
      &lt;ImageView android:src="@drawable/header"
          android:layout_width="fill_parent" 
          android:scaleType="fitXY"
          android:layout_height="fill_parent" 
          /&gt;
      &lt;RelativeLayout 
          android:layout_width="fill_parent"
          android:id="@+id/HeaderList" 
          android:layout_gravity="top"
          android:layout_height="wrap_content"
          &gt;
          &lt;TextView 
              android:layout_height="wrap_content"
              android:layout_width="wrap_content" 
              android:id="@+id/NameText"
              android:text="John Doe" 
              android:textColor="#FFFFFF"
              android:textSize="30sp" 
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true" 
              android:paddingLeft="4dp"
              android:paddingTop="4dp" 
              /&gt;
          &lt;TextView 
              android:layout_height="wrap_content"
              android:layout_width="wrap_content" 
              android:textColor="#FFFFFF"
              android:layout_alignParentLeft="true" 
              android:id="@+id/HoursText"
              android:text="170 hours" 
              android:textSize="23sp"
              android:layout_below="@+id/NameText" 
              android:paddingLeft="4dp" 
              /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>Does anybody have any suggestions for how best to make an image scale to the size of the contents of some layout?  I'm not concerned with the aspect ratio of the image, as it won't matter, I just want it to fill the background.</p>
  
  <p>Thanks!</p>