4

There are two functions to set notification icon setSmallIcon & setLargeIcon in NotificationCompat.Builder

I know that the small notification icon for mdpi density is 24x24dpi.

But what is the size of large notification icon for mdpi density?

Thank you.

Ahmed Ibrahim
  • 681
  • 8
  • 12
  • When you want to know that to be sure what size your large notification icon needs, it may be irrelevant. Icons will be imported in different densities in Android Studio and android should pick the correct density for each device. – Marcel Hofgesang Nov 20 '18 at 22:34
  • Hello Ahmed. Did my answer help you understand what the different notification sizes are and the dpi density associated with them? – Ishaan Javali Nov 20 '18 at 23:54

2 Answers2

5

For every device, you can use android.R.dimen.notification_large_icon_height and android.R.dimen.notification_large_icon_height to get the appropriate size for the device:

int largeIconHeight = context.resources
    .getDimensionPixelSize(android.R.dimen.notification_large_icon_height)
int largeIconWidth = context.resources
    .getDimensionPixelSize(android.R.dimen.notification_large_icon_width)

In practice, all devices use a square shape, so the two dimensions are always the same.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
1

For setSmallIcon refer to https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar

Also the best way to create the icon is with the asset manger (file -> new -> image asset) in android studio, otherwise the icon might not dim properly.

For the setLargeIcon I never used anything larger than 192x192 at xxxhdpi. It's pretty much a standard 48dp icon.

leonardkraemer
  • 6,573
  • 1
  • 31
  • 54