It looks as though style attributes are being inherited from the immediate parent only and not from the parent’s parent.
What MCU/Processor/Board and compiler are you using?
Using the simulator.
What do you experience?
I have a style where I set the font color to red.
Then I create the following:
- an outer container
- an inner container which is a child of the outer container
- a label which is a child of the inner container
If I add the style to the inner container, my label displays red text as I expect.
If I add the style to the outer container, my label displays default black text.
What do you expect?
I was expecting that style inheritance would cascade down multiple layers. But it seems as if inheritance is only happening from the immediate parent.
Code to reproduce
lv_style_init(&s1); lv_style_set_bg_color(&s1, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_style_set_text_color(&s1, LV_STATE_DEFAULT, LV_COLOR_RED); outerContainer = lv_cont_create(lv_scr_act(), NULL); innerContainer = lv_cont_create(outerContainer, NULL); #ifdef USE_NESTED_CONTAINERS lv_obj_add_style(outerContainer, LV_OBJ_PART_MAIN, &s1); // << label does not pick up red text color #else lv_obj_add_style(innerContainer, LV_OBJ_PART_MAIN, &s1); // << label will pick up red text color #endif lv_cont_set_fit4(innerContainer, LV_FIT_PARENT, LV_FIT_PARENT, LV_FIT_PARENT, LV_FIT_PARENT); lv_cont_set_layout(innerContainer, LV_LAYOUT_OFF); lbl = lv_label_create(innerContainer, NULL); lv_label_set_text(lbl, "Hello World");