Redeem Now
Read More
Read now

Dark theme in Android

Dark theme in Android :

Dark theme in Android:  displays dark surfaces across the majority of a UI. It’s designed to be a supplemental mode to default (or light) theme.

Dark theme is available in Android 10 (API level 29) and higher. It has many benefits:

Supporting the Dark theme in your app :

You can also use MaterialComponents’ dark theming:

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

We recommend using Material Design Components, since its color theming system (such as the theme attributes ?attr/colorSurface and ?attr/colorOnSurface) provides easy access to suitable colors. Of course, you can customize these attributes in your theme.

When running on devices running Android 9 or earlier, the recommended theme options are:

When running on Android 10 (API level 29) and higher, the recommended options are different, to allow the user to override the system default:

Note that if the user selects Light, then Battery Saver will not change that setting.

Each of the options map directly to one of the AppCompat.DayNight modes:

To switch the theme, call AppCompatDelegate.setDefaultNightMode().

Let’s do some real code:

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close