Hello! I want to invert the colour of label in monochrome display to highlight it. How can I do it? I've tried playing with styles but didn't succeed.
Hi,
Please copy here what have you tried so far. It should work with styles.
static lv_style_t style1, style2 , style3;
lv_obj_t *label4 = lv_label_create(container, NULL);
lv_style_copy(&style3, &lv_style_plain);
style3.text.color=LV_COLOR_WHITE;
lv_label_set_text(label4, "TestInverted");
style3.body.main_color = LV_COLOR_BLACK;
style3.body.grad_color = LV_COLOR_BLACK;
lv_obj_set_style(label4, &style3);
lv_obj_set_pos(label4, 0, 54);
After this the body colour of the label doesn't change to black. The label disappears(because of text.color=white).
By default, the background is not drawn behind labels. You can enable this with lv_label_set_body_draw
Tha background is bigger with body.hpad and body.vpadthan the label andlv_obj_set_pos` sets the position of the label and not the background.
Thanks! It works now.