1
On Android it is possible to make multiple style files, one for each version of the level of API
(16, 19, 21...), for each type of screen (xxxdp) and etc. But a question arose: there is some kind of inheritance among these files?
For example: I am working on a project where the minimum level of API
is 16 (JellyBean
). For this, I have 3 style files: one for the API 16
, one for the API 19
and one for the API 21
. However, within these files, I am defining the same thing (well to say) 3 times:
API 21:
<style name="AppTheme.Base" parent="android:Theme.Material.Light.NoActionBar.TranslucentDecor">
<item name="">@color/blue_500</item>
<item name="">@color/blue_700</item>
<item name="">@color/amber_a700</item>
<!--<item name="">true</item>-->
<item name="alertDialogProTheme">@style/Theme.AlertDialogPro.Material.Light</item>
</style>
<style name="DarkToolbar" parent="AppTheme.Base">
<item name="">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="">@color/abc_primary_text_material_dark</item>
</style>
</resources>
API 19:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/blue_500</item>
<item name="colorPrimaryDark">@color/blue_700</item>
<item name="colorAccent">@color/amber_a700</item>
<item name="">true</item>
<!--<item name="">true</item>-->
<item name="alertDialogProTheme">@style/Theme.AlertDialogPro.Material.Light</item>
</style>
<style name="DarkToolbar" parent="AppTheme.Base">
<item name="">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="">@color/abc_primary_text_material_dark</item>
</style>
</resources>
API 16:
<resources>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/blue_500</item>
<item name="colorPrimaryDark">@color/blue_700</item>
<item name="colorAccent">@color/amber_a700</item>
<!--<item name="">true</item>-->
<item name="alertDialogProTheme">@style/Theme.AlertDialogPro.Material.Light</item>
</style>
<style name="DarkToolbar" parent="AppTheme.Base">
<item name="">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="">/abc_primary_text_material_dark</item>
</style>
</resources>
My question is: if I set only once the colors used in colorPrimary
, colorPrimaryDark
and colorAccent
, as well as defining only once the style DarkToolbar
, i need to reset them for each summer of API, in other words, reassign the values for each version of Android that my app supports?
Editing: when trying to run the application using the above Xmls, I received an error stating that I should use the "Appcompat" theme instead of the "Material" theme, but the phone I’m testing is API 21 (Android 5.0), should support the Material theme. Any hint of what might be?
Thank you, array! That was exactly my question.
– Renan Lazarotto