Rahul
Rahul

Reputation: 372

Can we have Android Dark Mode Support for App Icons?

I am trying out with Dark Mode Theme Support for Android 10 for my App. I am able to work with all other things in Dark Mode except App Launcher Icon.

For reference, I was using below link

https://developer.android.com/guide/topics/ui/look-and-feel/darktheme

I know there is no such mention of App Icon change as per Day/Night theme changes.

Just for confirmation, need all your inputs on will it be possible to change the app icon as per change in theme from normal to dark and vice versa.

Thanks in advance.

Upvotes: 6

Views: 19189

Answers (8)

David Elmasllari
David Elmasllari

Reputation: 189

Dark mode is not supported for app icons (launcher icons).

Reason for this:

Some resource qualifiers like locale/density/version code do not change in day-to-day use and changing icons on those are supported. But we do not recommend changing app icons and labels based on frequently changing parameters and it is not supported at most places in system UI. Users create a memory map between apps and their corresponding icons/labels. Changing these frequently is disruptive to the user.

There is an issue filed with google for this and the decision is:

Won't Fix (Intended Behavior)

Issue tracker: https://issuetracker.google.com/issues/147521650?pli=1

Upvotes: 3

Ramanjeet
Ramanjeet

Reputation: 680

Apart from the app icon, other images colour can be modified :

Try using

android:drawableTint="@color/black" 

OR

app:tint="@color/black"

[

Add xml import by presing ALT+Enter or use following:

xmlns:app="http://schemas.android.com/apk/res-auto"

]

with your desired image.

UPDATE:

or Just use:

ivMyImageView.setColorFilter(ActivityCompat.getColor(context, android.R.color.holo_green_light))

PS: (Attribute drawableTint is only used in API level 23 and higher)

Upvotes: 1

D4rK
D4rK

Reputation: 309

Try to add mipmap-anydpi-v26 & mipmap-night-anydpi-v26 icons in your source code. I tried to add but is a little bit buggy. I theory icons support dark theme XD Here is an example

Upvotes: -1

Prashant Singh
Prashant Singh

Reputation: 75

To achieve Dark Mode for Icons in Android:

  1. Create the separate resource folder named values-night
  2. Inside values-night folder define your night theme (ex. theme.xml)
  3. Define all the desired colours you want in Dark mode inside theme.xml
  4. Now, inside your icon drawable define the icon tint attribute as follows-
  5. <vector android:height="24dp" android:tint="?attr/colorPrimaryDark" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"
  6. Using the above code, the icon colour will change based on colours defined in Dark and Light mode theme in your project

Pictures:

  1. res folder values-night

    res folder values-night

  2. define your Dark mode theme

    define your Dark mode theme

  3. change icon tint attribute of your Icons

    change icon tint attribute of your Icons

  4. light mode

    light mode

  5. Dark mode

    Dark mode

Upvotes: 4

dphans
dphans

Reputation: 1683

I think it possible, just launcher doesn't support display it.

BTW, I created new color resource into values-night and values, eg:

<!-- values-night/colors.xml -->
<color name="icon_background">#000000</color>
<!-- values/colors.xml -->
<color name="icon_background">#FFFFFF</color>

Then set background color into app icon:

<!-- mipmap/ic_launcher.xml -->
...
<background android:drawable="@color/icon_background" />
...
<!-- mipmap/ic_launcher_round.xml -->
...
<background android:drawable="@color/icon_background" />
...

App's icon now change when toggle dark mode..., but only for app swicher (icon display on top of window), but lancher does't update... I've tested on Android 11 on Pixel 4XL phone (using Google Launcher).

Anyone else?

Upvotes: 3

Vladimir Nitochkin
Vladimir Nitochkin

Reputation: 21

Well, you can use ure resource colors. Add night mode variation (right click values, New -> Values resource file, set file name "colors" and qualifier "Night mode". You can do variation of drawable specifically if you want.

The main drawback - it doesn't really stable. I don't know if it's just me, but I'm getting weird behaviour in emulator (sorry, can't test on device right now). Right after install icon is set with correct mode, but when you change to other it doesn't get updated. When you try to move icon it using current theme variation however.

Upvotes: 0

Prokash Sarkar
Prokash Sarkar

Reputation: 11873

Have you checked the Themes and styles section in documentation?

Your themes and styles should avoid hard-coded colors or icons intended for use under a light theme. You should use theme attributes (preferred) or night-qualified resources instead.

Here are the two most important theme attributes to know about:

?android:attr/textColorPrimary This is a general purpose text color. It is near-black in Light theme and near-white on Dark themes. It contains a disabled state.

?attr/colorControlNormal A general-purpose icon color. It contains a disabled state.

So the ?android:attr/textColorPrimary and ?attr/colorControlNormal will change based on the theme (black -> white & white -> black). I'm assuming we can set those colors as android:tint property to achieve the dark/white theme for vector icons. The con is your icons need to be black and white only.

Upvotes: 6

porwalshweta24
porwalshweta24

Reputation: 92

No, the app icon does not support dark mode.

Upvotes: 2

Related Questions