I am getting the infamous java.lang.OutOfMemoryError: bitmap size exceeds VM budget error
. I have several XML layouts and a lot of the elements have images (button backgrounds, Linear layout backgrounds, etc.) After going through the questions posted, like Strange out of memory issue while loading an image to a Bitmap object and external allocation too large for this process and OutofMemoryError: bitmap size exceeds VM budget (Android) and Android: Error loading images: OutOfMemoryError: bitmap size exceeds VM budget
I know I should use the BitMapFactory
methods. But all my images are defined in my XML
for example,
<ImageView
android:layout_width="80dp"
android:layout_height="20dp"
android:layout_marginBottom="3dp"
android:src="@drawable/username" />
How do I go from defining the images in my XML to defining them programatically so that I can try playing around with BitMapFactory
in hopes that it will eliminate my OOM
exception?