我正在研究一個包含多個主題的項目,並且每個主題都具有不同的屬性值。將多個樣式項目設置爲xml中的相同值
我想我的一些屬性是相同的價值,我知道我可以做到這一點。
<style name="theme_plain" parent="AppBaseThemeLight">
<item name="theme_backgroundtint">#FFF1F1F1</item>
<item name="theme_previewboxcolor">?theme_backgroundtint</item>
</style>
在我的代碼,然後訪問與
int boxcol = getIntFromAttr(R.attr.theme_previewboxcolor, themecolor);
這個值在當前主題設置應用程序是有問題的主題,這種方法效果很好,和theme_previewboxcolor = theme_backgroundtint從價值相同的主題。
但是,當前設置的主題是不同的主題時,theme_previewboxcolor會將theme_backgroundtint的值作爲當前設置的主題。我明白這是爲什麼,因爲theme_backgroundtint的當前值被設置爲當前主題的值。
我需要一種方法來有theme_previewboxcolor匹配這是在同一個主題設置theme_backgroundtint的價值,所以,即使在當前的一組主題是不同的,如在設置theme_previewboxcolor的價值和theme_backgroundtint的價值主題是一樣的。
感謝
僅僅使用引用的顏色有什麼問題:@ color/almost_white? – FunkTheMonk
問題是我有多個不同的子主題,所以在父類中,我想將theme_previewboxcolor設置爲theme_backgroundtint,以便即使當theme_backgroundtint隨後在子主題中被重寫時也是如此,就像您可以使用屬性一樣,所以絕對顏色參考不起作用 – Luke