Out of memory exception in Android when adding some image buttons
<p>I have written a small Android project that shows some (image)buttons. It works fine on my phone ( Galaxy S ), but when I try to run it on emulator, it gives the following error:
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget </p>

<p>Please note, first activity, has 8 image buttons, and it gives out of memory exception. When I remove 3 buttons, it works fine. Actually, it works fine as long as scrollView is inivisble and If I add those 3 removed buttons ( so, scrollView is going to be visible ), it gives out of memory error. I think, this "out of memory" exception is not related to the number of (image) buttons, but is related to background image. Here is my XML file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rootid"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" &gt;

        &lt;ImageView
            android:id="@+id/image"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="center"
            android:src="@drawable/backgrounmobile" /&gt;

        &lt;ScrollView
            android:id="@+id/ScrollView01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="left|top|bottom|right" &gt;

            &lt;LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/centerlayout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="right|top|bottom"
                android:layout_marginBottom="10dip"
                android:layout_marginLeft="10dip"
                android:layout_marginRight="20dip"
                android:layout_marginTop="0dip"
                android:orientation="vertical" &gt;

                &lt;Button
                    android:id="@+id/divan"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/divanbtn" /&gt;

                &lt;Button
                    android:id="@+id/boostan"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/boostanbtn" /&gt;

                &lt;Button
                    android:id="@+id/mavaez"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/mavaezbtn" /&gt;

                &lt;Button
                    android:id="@+id/hekayat"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/hekayatbtn" /&gt;

                &lt;Button
                    android:id="@+id/saadiname"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/saadinamebtn" /&gt;

                &lt;Button
                    android:id="@+id/settings"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/settingsbtn" /&gt;

                &lt;Button
                    android:id="@+id/about"
                    android:layout_width="160dip"
                    android:layout_height="110dip"
                    android:layout_gravity="center|top"
                    android:background="@drawable/aboutbtn" /&gt;
            &lt;/LinearLayout&gt;
        &lt;/ScrollView&gt;
    &lt;/FrameLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>Would you please help me?</p>
