Android 主题样式文件合并
Android Theme style file merge
简要描述一下我的情况,我有一个包含 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
你是这个意思吗?
将其放入您的 "Normal" 主题文件夹
<!--Standard-->
<style name="CommonTheme" parent="Theme.AppCompat.NoActionBar">
<!--Place all common elements here-->
</style>
<!--Standard-->
<style name="AppTheme" parent="CommonTheme">
</style>
将其放入您的 V21 文件夹
<!--V21-->
<style name="AppTheme" parent="CommonTheme">
<item name="android:navigationBarColor">?attr/colorPrimaryDark</item>
<item name="android:statusBarColor">?attr/colorPrimaryDark</item>
</style>
简要描述一下我的情况,我有一个包含 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
你是这个意思吗?
将其放入您的 "Normal" 主题文件夹
<!--Standard-->
<style name="CommonTheme" parent="Theme.AppCompat.NoActionBar">
<!--Place all common elements here-->
</style>
<!--Standard-->
<style name="AppTheme" parent="CommonTheme">
</style>
将其放入您的 V21 文件夹
<!--V21-->
<style name="AppTheme" parent="CommonTheme">
<item name="android:navigationBarColor">?attr/colorPrimaryDark</item>
<item name="android:statusBarColor">?attr/colorPrimaryDark</item>
</style>