title: Android layouts - offsetting a background image in xml
body: <p>I have a large png that I would like to use as a background on different layouts, but offset it so that I can have different parts showing (much like you can in CSS), preferable in the xml.</p>
  
  <p>My main layout for the activity contains the following xml:</p>
  
  <pre><code>&lt;LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@layout/bg1"&gt;
  </code></pre>
  
  <p>Layout bg1 consists of the following xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;bitmap
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/big_image"
  android:layout_marginTop="50sp"
  android:paddingTop="50sp"
  android:gravity="top|left" /&gt;
  </code></pre>
  
  <p>The gravity property works as expected but margins and paddings are ignored, presumably because I'm working on a bitmap object rather than a layout. What I want to do is set these to a minus amount so that only part of the picture is shown. I've tried using a shape but that only wraps the content whereas I need to fill the entire background.</p>
  
  <p>Any suggestions would be gratefully received. Thanks.</p>