Reputation: 4113
I am giving notification by a background service. In notification i am displaying an image , image dimensions are 15*15. But when image is showed it automatically streches to big size , so it became blur. I haven't specified the image size in my program. Why this is happening
Upvotes: 6
Views: 19929
Reputation: 54811
Guildlines says 24x24, that is for mdpi.
Applying the conversion dp*density/160
you get these pixels resolutions:
ldpi 18x18
mdpi 24x24
hdpi 36x36
xhdpi 48x48
(The guidelines actually now list these 4 dimensions)
If you're creating an image, or resizing an image to fix the large notification image area, you can get the pixel dimensions like so:
int width = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
int height = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
See https://developer.android.com/reference/android/R.dimen.html#notification_large_icon_height
Upvotes: 8
Reputation: 6080
Refer status bar icon guidelines: http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
For hdpi status bar icon image should be 38px height (24x38),
mdpi - 16x25
ldpi - 12x19
Upvotes: 10
Reputation: 39603
That is because when specifying dimensions in Java it is automatically regarded as a pixel value.
You will have to implement a helper method somewhere, best in a helper class, which calculates and returns a density independent pixel value based on the provided pixel value.
The equation is px = dip * (density / 160)
from which we get that dip = px / (density/160)
.
This answer here is even better actually.
Upvotes: 0