Android: how to stop Android 1.6+ from scaling images

I updated my build to build against Android 1.6, and now my bitmaps are scaled down on high density screens. I do NOT want this behavior. I have done this:

http://blog.tomgibara.com/post/190539066/android-unscaled-bitmaps

but STILL images are scaled, that is, UNLESS I set them to a specific height and width. If I use wrap_content , they are reduced.

I have an image downloader using an unscaled raster downloader to create this way:

 Bitmap bm = UnscaledBitmapLoader.loadFromResource(imageBufferInputStream); drawable = new BitmapDrawable(bm); 

which I then assign ImageView as follows:

 imageView.setImageDrawable( copyBitmapDrawable( (BitmapDrawable) drawable) ); 
+1
source share
4 answers

Wrapping a bitmap using Drawable is a problem. Drawable scales Bitmap . Instead of using Drawable assign the Bitmap to the ImageView directly using imageView.setImageBitmap(Bitmap) .

+1
source

So that the image does not scale when loading from the resource (for example, from BitmapFactory.decodeResource), you need to find it in res / drawable-nodpi instead of the usual drawable, drawable-ldpi, etc.

+3
source

Using

 new BitmapDrawable(this.getResources(), bmp); 

instead

  new BitmapDrawable(bmp); 

should solve the problem.

+2
source

Use ImageView.ScaleType . The CENTER constant has no scaling, so I assume you are looking.

By the way, do you use pixels or dips as units of size? Using dips (independent of pixel density) is a means of standardizing display at multiple resolutions. You will find a couple of tips here .

0
source

All Articles