0

I have an icon with 48x48 dimension. And I put it under the drawable-mdpi folder.

Then I tried to get its size:

BitmapDrawable bd = (BitmapDrawable) context.getResources().getDrawable(R.drawable.ic);
Bitmap bm = bd.getBitmap();
Log.d("render", "icon height:" + bm.getHeight());
canvas.drawBitmap(bd.getBitmap(), 0, 0, p);

From the logcat, it prints: icon height: 72.

Then I put the icon under drawable-hdpi, then I got: icon height: 48.

Then I put the icon under drawable-ldpi, then I got: icon height: 96.

What is going on?

hguser
  • 35,079
  • 54
  • 159
  • 293
  • But the icons size is 48x48, and through the android developer I should put the under the `drawable-mdpi`. Why I have to put it under the `drawable-hdpi`? – hguser May 04 '13 at 02:43
  • 1
    Don't take it quite so literally. Read through the answer to understand what's going on. You'll also want to read through the linked docs which you seem to not have fully absorbed quite yet. The Android Developers site certainly doesn't say to always put it in `drawable-mdpi`. – kabuko May 04 '13 at 02:51
  • Definitely the same problem described in the other question http://stackoverflow.com/questions/8198291/bitmap-getwidth-returns-wrong-value – HalR May 04 '13 at 02:56
  • OK, I will read again. – hguser May 04 '13 at 02:57

1 Answers1

0

As per developer console image size is work with different device screen density.

If you have to used one image with all device then make drawable folder and put your image.

This is not good but one hack solution for simple image scale issue.

Harshid
  • 5,701
  • 4
  • 37
  • 50