Reputation: 372
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
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
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
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
Reputation: 75
To achieve Dark Mode for Icons in Android:
<vector android:height="24dp" android:tint="?attr/colorPrimaryDark" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"
Pictures:
res folder values-night
define your Dark mode theme
change icon tint attribute of your Icons
light mode
Dark mode
Upvotes: 4
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
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
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