Lvgl: Invert label color in monochrome display

Created on 15 Aug 2018  路  4Comments  路  Source: lvgl/lvgl

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.

question

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MShahrukh0 picture MShahrukh0  路  6Comments

ghost picture ghost  路  6Comments

Moo2017 picture Moo2017  路  3Comments

mharizanov picture mharizanov  路  4Comments

defconhaya picture defconhaya  路  3Comments