Android: Images from XML layout to Bitmaps in Code to solve OOM error

yabbadabba

New Member
I am getting the infamous \[code\]java.lang.OutOfMemoryError: bitmap size exceeds VM budget error\[/code\]. 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 Android: 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 \[code\]BitMapFactory\[/code\] methods. But all my images are defined in my \[code\]XML\[/code\] for example, \[code\] <ImageView android:layout_width="80dp" android:layout_height="20dp" android:layout_marginBottom="3dp" android:src="http://stackoverflow.com/questions/11160612/@drawable/username" />\[/code\]How do I go from defining the images in my XML to defining them programatically so that I can try playing around with \[code\]BitMapFactory\[/code\] in hopes that it will eliminate my \[code\]OOM\[/code\] exception?
 
Back
Top