In the newer version of Android Studio, I cant see styles.xml
, but in the values directory, there are two new XML, theme.xml
and theme.xml(night)
.
Does it actually replace the work of styles.xml
OR If different what is the difference between them??
2
Answers
Using XML attributes in
resvalues
doesn’t actually depend on the file name, you can define any of which like a<string>
in another file like style.xml.Even you can change the name of the
style.xml
to something that you’d like to.In recent Android studio versions
styles.xml
is replaced bythemes.xml
, but the latter provides a night version for dark mode.styles is a collection of attributes which define how a certain ui looks like ex: editText or textView a theme meanwhile decides how your whole app looks(a single theme can have multiple styles depends on your design), the difference between both themes day and night is to make your app adapt to day mode and night mode. Because now in android OS you can force dark mode.
As a developer you need to have your app prepared for this.
How to use this
give different colors to both your themes labelled in items(below is from a theme file)
To use in textview or button or layout file simpley just:
Now when user force switch on dark mode in developer mode in their phone , your app will immediately adapt to it and change colors of its UI.
More info can be found here – https://developer.android.com/guide/topics/ui/look-and-feel/themes