Android 主题样式文件合并

Asy*_*ode 3 android android-xml android-resources android-studio android-styles

简而言之,我有一个带有style.xml和的多主题项目style.xml(v21)。这两个版本唯一的区别是在v21版本的每个主题中都额外增加了这两行:
<item name="android:navigationBarColor">?attr/colorPrimaryDark</item> <item name="android:statusBarColor">?attr/colorPrimaryDark</item>

而且我不维护两个样式文件,因为它们太熟悉了,所以有什么办法可以合并这两个样式xml文件,或者使v21一个扩展style.xml,当我要进行一些修改时,我只需要与style.xml

Kuf*_*ffs 5

你是这个意思吗?

把它放在你的“普通”主题文件夹中

<!--Standard-->
<style name="CommonTheme" parent="Theme.AppCompat.NoActionBar">
    <!--Place all common elements here-->
</style>

<!--Standard-->
<style name="AppTheme" parent="CommonTheme">

</style>
Run Code Online (Sandbox Code Playgroud)

把它放在你的 V21 文件夹中

<!--V21-->
<style name="AppTheme" parent="CommonTheme">
    <item name="android:navigationBarColor">?attr/colorPrimaryDark</item>
    <item name="android:statusBarColor">?attr/colorPrimaryDark</item>
</style>
Run Code Online (Sandbox Code Playgroud)