I’m initializing a Drawable like this:
Drawable drawable = new BitmapDrawable(bitmap);
The dimensions of the bitmap are 50 x 77 (confirmed with the debugger, this values are set in the fields mWidth and mHeight).
But my drawable initializes size 33 x 51, why is this?
I examined the drawable variable just after this line, the values are:
mBitmapWidth = 33
mBitmapHeight = 51
And
drawable.getIntrinsicWidth();
drawable.getIntrinsicHeight();
also returns 33 x 51.
But the drawable also has the bitmap field mBitmap, which has the correct size 50 x 77. So why is the drawable being initialized with 33 x 51?
The dimensions of the
Bitmapare in pixels whereas the dimensions of theDrawableare in dp (density dependent pixels).In your case, the density of your display is probably something like 1.5:
Note that the drawable dimensions are updated when settings the density via
setTargetDensitymethod.