 <p>Xml Layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/main" &gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Change" android:onClick="changeBack" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Add this code to your Activity</p> <pre><code>public boolean firstImage = true; public void changeBack(View view) { if (firstImage) ((LinearLayout)findViewById(R.id.main)).setBackgroundResource(R.drawable.secondimage); else ((LinearLayout)findViewById(R.id.main)).setBackgroundResource(R.drawable.firstimage); firstImage = !firstImage; } </code></pre>