android - Android RRO - 覆盖自定义属性
问题描述
在我的主要 Android 应用程序中,我定义了一个属性,它指向某种颜色。它看起来像这样:
<declare-styleable name="ThemeColors">
<attr name="my_button_background" format="color" />
</declare-styleable>
然后我有我的风格
<style name="MyTheme">
<item name="my_button_background">@color/color_blue</item>
</style>
之后,我像这样设置我的按钮:
<Button
style="@style/some_style"
android:text="@string/some_text"
android:background="?attr/my_button_background"/>
现在,在我的叠加应用程序中,如果我做这样的事情,它可以完美运行
<color name="color_blue">#FFFF00</color>
但是,如果我想使用它来覆盖属性,它就不起作用。
<color name="my_button_background">#FFFF00</color>
color_blue
另一种解决方案是用类似的东西包装color_button_background
,然后将其用作我的属性的指针,并在我的 RRO 中覆盖它。但它只会带来很多混乱。而且我有很多属性,这将使这项工作更加耗时。
有人可以帮我解决这个问题吗?有没有办法覆盖属性?我尝试用谷歌搜索这个,但我没有找到解决方案。
解决方案
推荐阅读
- apple-push-notifications - 在 RubyMotion 中获取用于推送通知的 iOS 设备令牌
- javascript - 如何通过在 React Native 中单击按钮来更改动态生成的 JSX 的样式
- python - pytest 在导入以 test 开头的函数时在指定目录之外查找测试
- javascript - 使用 jquery 更改视频质量
- c# - 将具有许多前导零的字符串转换为十进制
- gremlin - 如何将自定义 DSL 添加到 Gremlin 控制台
- laravel - 如果 url 中没有 index.php,Laravel 7.10 新安装不起作用
- reactjs - 在 ReactJS 中设置条件 onClick 行为
- typo3 - TYPO3 站点 config.yaml 在自己的扩展中外包?
- python - Python 错误:AttributeError:“NoneType”对象没有属性“to_excel”