I need to create a gallery type application. Where i need display many image and give the zooming and sliding effects.
Now I am using android.widget.Gallery
and setting the image to imageview
in the getview
of my gallery Adapter
class (extends BaseAdapter
). Me set image using bitmap, which is set by the following code
Bitmap mBitmap = BitmapFactory.decodeFile(imagePathArray.get(position));
imageview.setImageBitmap(mBitmap);
It works fine at first, but after moving to third or fourth image the application crash with the following error
ERROR/AndroidRuntime(12184): FATAL EXCEPTION: main
ERROR/AndroidRuntime(12184): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at the decodeFile statement.
When i searched for bitmap size exceeds VM budget
, i got a lot of solutions like android-strange-out-of-memory-issue. But all solutions are reducing the image quality.
What is the best method to display image in good quality and with less memory, that will not cause bitmap size exceeds VM budget
?
Any suggestion?
Thank you