Hello I have a viewpager with several pages(using a fragment state pager), and some pngs as backgrounds to those pages. I already followed the Displaying Bitmaps in the Ui (
Building up on @coderek answer I seem to have solved this by fetching bitmaps without scaling them for specific densities:
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resource, opts);
((ImageView) view).setImageBitmap(bitmap);
Using an image from drawable
folder in an xxhdpi
device resulted in up to 8 times more memory being allocated!
P.S.:
You can also down sample the drawable if the resolution is too big:
opts.inSampleSize = 2;