0

On MIUI devices, there is an option to choose the notification style between Android and MIUI. When I select android style, my icon is displayed as a gray square, and when MIUI style is displayed, the icon is displayed correctly. I noticed that the Gmail icon changes its display depending on the selected style.

Android Style:

Android Style

MIUI STYLE:

MIUI Style

When I chose the android style, my icon looks like this:

My Icon

When I chose MIUI style, my icon is displayed correctly with all colors.

At the moment, I'm setting the icon like this:

val icon = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
    R.mipmap.ic_launcher else R.drawable.ic_app_icon
notificationBuilder.setSmallIcon(icon)

How do I set an icon to achieve the same result as gmail? Maybe I need to make some special icon?

1 Answer 1

0

Solution:

notificationBuilder.setSmallIcon(R.drawable.miui_style, 2) // It will be displayed when MIUI style is selected
notificationBuilder.setSmallIcon(R.drawable.android_style_icon,1)// It will be displayed when ANDROID style is selected

Use Builder setSmallIcon(int icon, int level) to set the icon level

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.