Search code examples
androidxmlpush-notificationandroid-vectordrawable

Can we use VectorDrawable or VectorXML as icons for push notifications in android?


I am using PNG image but its size is getting too big so I have to compromise with its quality. So i was thinking vectors may be the another way around ? Example will be a great help.


Solution

  • Can we use VectorDrawable or VectorXML as icons for push notifications?

    Yes, just call the vector drawable the standard way for notifications:

    .setSmallIcon(R.drawable.my_vector)
    

    In order to use the transparency (notification icons are only white and/or transparent), you will have to use the alpha channels when settings the colors in the vector XML, meaning #00000000 for transparent and #FFFFFFFF for white.