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

后端 未结 6 1250
故里飘歌
故里飘歌 2021-01-03 21:06

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 gr

6条回答
  •  梦毁少年i
    2021-01-03 21:34

    If you insist to use Vector drawable try converting it to bitmap :

    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.my_vector_drawable);
                        mBuilder = new NotificationCompat.Builder(context)
                                .setLargeIcon(bitmap)
                                .setOngoing(!cancelable);
    
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                            mBuilder.setSmallIcon(getNotificationIcon());
                        }
    

提交回复
热议问题