I have a bitmap with the dimensions of 537 * 233
. This is displayed in my fragment.
I am calculating the height of this bitmap through code as well.
I came to know that simply using,
image.getHeight()
will always return 0.
Then I found that putting the same in overridden method onGlobalLayout()
will give the actual height.
I did that. See my SO post for link.
Now the height I am getting is 155.
I also tried getting the height with,
BitmapDrawable bd = (BitmapDrawable) getResources().getDrawable(R.drawable.chart);
imgHeight = bd.getBitmap().getHeight();
Again the height I am getting is 155.
According to the above dimensions, the height should be 233
.
I am seeing the same height in emulator too.
Why is the difference and/or what I consider to be its actual height ?
UPDATE:
ok, my chart was in drawable-hdpi
and the density of my device is 160
. So when I put the chart image in drawable
folder, I got the correct height. But then if the chart height is fixed (233), why in some devices I am getting the chart height big enough to overlap my bottom timeline. Although I know a bit that this may be because of approximate values and not accurate values (density, resolution) that is causing the in-differences. But then, Any ideas how to fix that ?