Android - theme.xml and theme.xml(night)
Asked Answered
H

3

8

In newer version of Android Studio In values directory there is theme.xml and theme.xml(night) Can any point out differences between them ?? Does it replace styles.xml ??

Hive answered 14/10, 2020 at 12:10 Comment(0)
P
7

As specified in the latest Android Studio 4.1 features :

Every new project will be having two theme xml files : one for light and other one for dark mode.

Actually, in the older versions of Android studio, if you want to enable dark mode in your app, you have to manually create and define the properties in your dark theme XML file, but now it is automatically generated as mostly all new apps are moving towards dark mode in their applications.

You can still delete these files from your Android studio project if it doesn't fit in your use-case.

Pindaric answered 14/10, 2020 at 12:36 Comment(1)
So, what is the main difference between themes.xml and styles.xml files?Creighton
B
7

In values directory there is theme.xml and theme.xml(night)

There are 2 folders res\values and res\values-night and in each folder there is the theme.xml file.

The -night is a qualifier to define the resources (styles,dimens..) used in the Dark(night) Theme.

Byplay answered 14/10, 2020 at 12:45 Comment(0)
S
1

he DayNight theme and the resources used with the -night qualifier were introduced with the Support Library 23.2 in the 2016 Dark Theme has been introduced for devices where users can change the theme configuration of their android device.

Theme.xml file : This file will be used by default in your app.

Theme.xml file (night) : This file all the attributes will be used automatically when the user has enabled Dark Theme in their android device.

Does it replace styles.xml ?? : You will have to set different styles as well so that your UI views are properly visible to the user w.r.t. color schemes.

Subnormal answered 14/10, 2020 at 12:22 Comment(1)
It is not totally correct. The DayNight theme and the resources used with the -night qualifier were introduced with the Support Library 23.2 in the 2016.Byplay

© 2022 - 2024 — McMap. All rights reserved.