Change screen background color from code


I am trying to change a screen/display’s color from code. Initially the background is black - set from Squareline.

Reading the docs, I tried the following code without success:

lv_color_t my_color = lv_color_hex(0xFFFFFF);
lv_disp_t * d = lv_obj_get_disp(ui_SettingsScreen);
lv_disp_set_bg_color(d, my_color);

Any ideas why this is not working? I will keep trying.
Thank you!


The background is visible only is the screen has bg_opa != 255.

Maybe you want to change the the screen’s background color and not the display’s. (Display is the physical display and screen is an LVGL object.)

E.g. lv_obj_set_style_bg_color(ui_screen_1, lv_color_hex(0xffffff), 0);

1 Like

Works perfectly. Thank you so much, as always!

1 Like