How to modify the background color or image of `disp`

I try to modify the background color or image using the API:
lv_disp_set_bg_colorlv_disp_set_bg_image; But it doesn’t work at all;What’s wrong?

It probably depends on which version of LVGL you are using.

I am using the master GIT version, so if you are on V7 to set the screen background colour I do this.
Don’t know if it is the right way or the only way but it works for me.

   static lv_style_t blue_bg_style;
   lv_style_set_bg_color(&blue_bg_style, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x00, 0x00, 0x40));
   lv_obj_add_style(lv_scr_act(), LV_OBJ_PART_MAIN, &blue_bg_style);

Hi @as564335sa,

The solution @Benedict_Hewson has given is perfectly valid, you can also use this shorter version if you would like:

	lv_obj_set_style_local_bg_color (lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
	lv_obj_set_style_local_bg_opa( lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);  

Kind Regards,


My version is v7.1.0. Your method is ok, but I don’t know why the API doesn’t work.

The display’s background is visible only when the screen is transparent.

那如何去设置 bg-image?