问题:
Consider this:考虑一下:
styles.xml样式文件
<style name="BlueTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="theme_color">@color/theme_color_blue</item>
</style>
attrs.xml属性文件
<attr name="theme_color" format="reference" />
color.xml颜色文件
<color name="theme_color_blue">#ff0071d3</color>
So the theme color is referenced by the theme.所以主题颜色是由主题引用的。 How can I get the theme_color (reference) programmatically?如何以编程方式获取 theme_color (参考)? Normally I would use getResources().getColor()
but not in this case because it's referenced!通常我会使用getResources().getColor()
但在这种情况下不会使用,因为它被引用了!
解决方案:
参考一: https://en.stackoom.com/question/1AUhG参考二: https://stackoom.com/question/1AUhG