android - 在 21 岁以下的 Android 中使用 ?attr 失败
问题描述
我在我的 Android 应用程序中使用明暗模式。我在values文件夹中做了一个attrs.xml文件。我调整了 attr 值。我在styles.xml 中为夜间和灯光模式创建了2 个样式。所以它适用于 21 以上的 Android,但不适用于 21 以下。我该如何修复它????
attrs.xml
<declare-styleable name="ds">
<attr name="backact" format="color"/>
<attr name="toolbar_backact" format="color"/>
<attr name="textcolor" format="color"/>
</declare-styleable>
样式.xml
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="backact">@color/backact</item>
<item name="toolbar_backact">@color/toolbar_backact</item>
<item name="textcolor">@color/textcolor</item>
</style>
<style name="DarkTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="backact">#0a131c</item>
<item name="toolbar_backact">#19242e</item>
<item name="textcolor">#FDFDFD</item>
</style>
解决方案
推荐阅读
- java - Java允许运行私有方法吗?有人可以解释为什么吗?
- r - mclapply() 的性能明显比 lapply() 差。我怎样才能加快速度?
- angular - Webstorm:“必须是左值”是什么意思
- c# - C#上的二维数组
- php - Postman 的响应显示 200,但 Android 返回 403
- python - Pandas 对 DateTime 列的错误排序
- google-chrome-extension - Chrome 扩展电子邮件问题中的 Google Oauth 集成
- c# - 创建新邮件后,RibbonDropDownItems 不可见
- google-apps-script - 使用 Google Apps 脚本插入脚本文件
- c# - C# 有效读取流内容并限制读取量