Android: How to stop Android 1.6+ from scaling images

前端 未结 4 374
半阙折子戏
半阙折子戏 2021-01-03 17:09

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 gave this a shot:

http://

相关标签:
4条回答
  • 2021-01-03 17:45

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

    0 讨论(0)
  • 2021-01-03 17:59

    Using

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

    instead of

     new BitmapDrawable(bmp);
    

    should solve the issue.

    0 讨论(0)
  • 2021-01-03 18:00

    In order to have an image not scaled when loading it from a resource (e.g. with BitmapFactory.decodeResource) you have to locate it in res/drawable-nodpi instead of the usual drawable, drawable-ldpi and so on.

    0 讨论(0)
  • 2021-01-03 18:08

    Use ImageView.ScaleType. The CENTER constant preforms no scaling, so I guess that's what you are looking for.

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

    0 讨论(0)
提交回复
热议问题