I am using the new stable version of Android Studio 4.1.1
. When I create a new Android project, by default there are 2 themes.xml
files one under values
and an other under values-night
. But I don't see the styles.xml
.
The themes.xml
looks like this -
<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>
My questions are -
styles.xml
for my individual views or could I start adding in the themes.xml
as well?styles.xml
should I create them one under values
and an other under values-night
?themes.xml
missing colorAccent
?Do I need to create a styles.xml for my individual views or could I start adding in the themes.xml as well?
There is nothing stopping you putting styles for individual views into themes.xml
. Presumably, Google's vision here is to have theme-related stuff in themes.xml
and have other styles in a styles.xml
that you create.
In the end, filenames in res/values/
and related directories (e.g., res/values-night/
) do not matter much. You can put styles and themes in styles.xml
, themes.xml
, maria.xml
, or whatever.
If I need to create a styles.xml should I create them one under values and an other under values-night?
Only if you need to have different styles for regular use and for night mode.
Why is the themes.xml missing colorAccent?
Android Studio 4.1 is not using AppCompat
themes. Instead, it is using MaterialComponents
themes, from the Material Components for Android. Those themes use a different color system than does AppCompat.