Android仅新项目主题文件
我正在使用Android Studio的新稳定版本Android仅新项目主题文件,android,kotlin,android-styles,android-darkmode,Android,Kotlin,Android Styles,Android Darkmode,我正在使用Android Studio的新稳定版本4.1.1。当我创建一个新的Android项目时,默认情况下有2个themes.xml文件,一个在values下,另一个在values下。但是我没有看到styles.xml themes.xml如下所示- <style name="Theme.SampleApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
4.1.1
。当我创建一个新的Android项目时,默认情况下有2个themes.xml
文件,一个在values
下,另一个在values
下。但是我没有看到styles.xml
themes.xml
如下所示-
<style name="Theme.SampleApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
@颜色/紫色500
@颜色/紫色\u 700
@颜色/白色
@颜色/青色200
@颜色/青绿色700
@颜色/黑色
?attr/colorPrimaryVariant
我的问题是-
style.xml
,或者我是否可以开始添加themes.xml
style.xml
,我应该在values
下创建一个,在values
下创建另一个吗themes.xml
缺少colorAccent
themes.xml
。据推测,谷歌的愿景是在themes.xml
中包含与主题相关的内容,并在您创建的style.xml
中包含其他样式
最后,res/values/
和相关目录(例如,res/values/
)中的文件名并不重要。您可以将样式和主题放在styles.xml
、themes.xml
、maria.xml
或其他任何位置
如果我需要创建styles.xml,我应该在values下创建一个styles.xml,在values下创建另一个styles.xml吗
只有当你需要有不同的风格,用于常规使用和夜间模式
为什么themes.xml缺少colorAccent
Android Studio 4.1没有使用AppCompat主题。相反,它使用Android材质组件中的
MaterialComponents
主题。这些主题使用的比AppCompat更多。这就解释了一切……因此,colorAccent的等价物应该是colorSecondary