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
3 Answers
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

- 6,026
- 4
- 43
- 51
The small icons
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)
Dynamically sized large icons
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

- 54,145
- 21
- 145
- 203
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.

- 1
- 1

- 39,405
- 19
- 98
- 102