I am using the new Theme.AppCompat.DayNight
added in Android Support Library 23.2
On Android 5.1 it works well.
On Android 6.0, act
As of now, no Gradle dependency is needed to enable the night mode other than androidx.appcompat:appcompat:1.0.2
which will already be present. Make sure to change the default theme from Theme.AppCompat.Light.DarkActionBar
to Theme.AppCompat.DayNight.DarkActionBar
in the styles.xml file and then do AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
to switch to the night mode. I have tested it in APIv23(Android 6.0) and above and it is working fine.
For a better explanation see this codelab by Android