diff --git a/src/others/xml/lv_xml_style.c b/src/others/xml/lv_xml_style.c
index ff7bf533b0..47c459924e 100644
--- a/src/others/xml/lv_xml_style.c
+++ b/src/others/xml/lv_xml_style.c
@@ -124,13 +124,31 @@ lv_result_t lv_xml_style_register(lv_xml_component_scope_t * scope, const char *
if(value[0] == '#') {
const char * value_clean = &value[1];
+ bool const_found = false;
lv_xml_const_t * c;
LV_LL_READ(&scope->const_ll, c) {
if(lv_streq(c->name, value_clean)) {
value = c->value;
+ const_found = true;
break;
}
}
+ if(!const_found) {
+ lv_xml_component_scope_t * global_scope = lv_xml_component_get_scope("globals");
+ if(global_scope) {
+ LV_LL_READ(&global_scope->const_ll, c) {
+ if(lv_streq(c->name, value_clean)) {
+ value = c->value;
+ const_found = true;
+ break;
+ }
+ }
+ }
+ }
+ if(!const_found) {
+ LV_LOG_WARN("Constant `%s` is not found", value_clean);
+ continue;
+ }
}
if(lv_streq(value, "remove")) {
diff --git a/tests/src/test_assets/xml/view2.xml b/tests/src/test_assets/xml/view2.xml
index 117b41c9ba..c4a5cb2431 100644
--- a/tests/src/test_assets/xml/view2.xml
+++ b/tests/src/test_assets/xml/view2.xml
@@ -9,7 +9,7 @@
-
+