Issue
I have a an image image.png
in the drawable folder (not any of the other drawable-hdpi, etc. folders).
This image's size is 50x50
. But when I load it from my application like so:
BitmapFactory.decodeResource(getResources(), R.drawable.image)
and then I check the size with getWidth()
and getHeight()
, I get 150x150
.
Can anyone please explain how to calculate this 150x150
loaded size? (Not programmatically, I just want to know if there's a formula I could have used to tell that the image would be loaded to 150x150
)
Also, is this 150x150
in pixels?
Thanks!
Solution
- Yes, the value is in pixel unit, make use of the java doc my friend~
- If you want the image size to stay unchanged, put it into
drawable-nodpi
- If you put the image in the
drawable
, it is the same as in thedrawable-mdpi
, as the first Android-powered device, the T-Mobile G1 is a normal size and mdpi (medium) density :) And the no magic formula :
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpiThat is, in your case, likely developing on a xxhdpi device, 480/160*50=150, remember android is designed to be visualize all the ui elements at the same size on all screens, so the higher density , the larger scaled image .
Answered By - Neil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.