Android – theme.xml 和 theme.xml(夜间)

huangapple go评论72阅读模式
英文:

Android - theme.xml and theme.xml(night)

问题

在较新版本的Android Studio中,在"values"目录下有"theme.xml"和"theme.xml(night)"。
有人可以指出它们之间的区别吗?
它会取代"styles.xml"吗?

英文:

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 ??

答案1

得分: 7

根据最新的 Android Studio 4.1 特性

> 每个新项目都将拥有两个主题 XML 文件:一个用于浅色主题,另一个用于深色模式。

实际上,在较早的 Android Studio 版本中,如果您想在应用程序中启用深色模式,您必须手动创建并在深色主题 XML 文件中定义属性,但现在它会自动生成,因为几乎所有新应用都在向深色模式迁移。

如果不适合您的用例,仍然可以从您的 Android Studio 项目中删除这些文件。

英文:

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.

答案2

得分: 5

>在 values 目录下有 theme.xml 和 theme.xml(night)

2 个文件夹 res\valuesres\values-night,并且每个文件夹中都有 theme.xml 文件。

-night 是一个限定符,用于定义在深色(夜间)主题中使用的资源(样式、尺寸等)。

英文:

>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.

答案3

得分: 1

DayNight主题和-night限定符的资源是在Support Library 23.2中引入的,2016年引入了Dark Theme,适用于用户可以更改其Android设备主题配置的设备。

Theme.xml文件:此文件将在您的应用程序中默认使用。

Theme.xml文件(night):当用户在其Android设备上启用了Dark Theme时,此文件中的所有属性将自动使用。

它是否替代styles.xml?:您还必须设置不同的样式,以便用户可以根据颜色方案正确看到您的UI视图。

英文:

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.

huangapple
  • 本文由 发表于 2020年10月14日 20:10:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/64352950.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定