Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: inverted color on dark mode

I have troubles with some imageview on certain Android phones.

It seems that the dark mode invert the color of certains assets (not all, it seems only black/dark gray ones)

An example.

Image on light/normal mode (correct)

Image on dark mode

I cannot find a way to avoid this. Is there some kind of properties that protect the image from being inverted?

like image 634
Davide Berra Avatar asked Jan 04 '21 21:01

Davide Berra


2 Answers

you can use setForceDarkAllowed(false) if you just want to apply this to one View.

Or you can change the attributes/colors in your res/values-night folder, which holds all colors that are used in case the dark mode is activated.

like image 62
A Honey Bustard Avatar answered Oct 23 '22 16:10

A Honey Bustard


You can disable Dark mode on your app by using:

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

If you want to disable it on a view, you can

  1. Use light style for a specific view

  2. Use android:forceDarkAllowed="false"

like image 41
AliSh Avatar answered Oct 23 '22 18:10

AliSh