Wrong size from Drawable.getIntrinsicWidth()
|
I download image with this code:
This image has size 20x20. But drawable.getIntrinsicWidth() and drawable.getIntrinsicHeight() return 27. And image looks larger. How I can fix it? |
||
feedback
|
BitmapDrawable must scale bitmap to compensate for different screen densities. If you need it to draw pixel-for-pixel, try setting Drawable's source density & target density to same value. To do this, you need slightly different objects to work with. Instead of
use
If you don't have context (which you should), you can use application context, see e.g. Using Application context everywhere? Since bitmap's density is set to resources' density, which is actual device's screen's density, it should draw without scaling. |