当它是参考(主题)时以编程方式获取颜色值 - Get color value programmatically when it's a reference (theme)

问题:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章