【发布时间】:2021-01-20 11:10:08
【问题描述】:
在 Android 开发中,我可以提供 API depending resources。我有一个自定义主题,我想用两个 API 29 及更高版本的新条目扩展为 described here。
所以文件/文件夹结构如下所示:
res
- values
- dark_theme.xml
- light_theme.xml
- values-v29
- dark_theme.xml
- light_theme.xml
如何在values-v29\dark_theme.xml 和values\light_theme.xml 中扩展values\dark_theme.xml 和values\light_theme.xml 中定义的主题(向现有主题添加项目)?
假设我想使用"edge-to-edge" feature 的新选项扩展浅色主题。我需要如何设置主题,这样我就不需要将原始主题中的所有值复制到-v29文件夹中的主题中?
values\light_theme.xml的内容:
<resources>
<style name="AppTheme_Light" parent="BaseAppTheme">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_light</item>
...
</style>
</resources>
在不处理整个主题的情况下,使用values 文件夹中主题中已定义的项目,文件需要看起来如何?
values-29\light_theme.xml的内容:
<style name="AppTheme_Light" parent="BaseAppTheme">
...How to ensure all the previous items defined in values\light_theme.xml are used here?
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
【问题讨论】:
标签: android android-theme