Page 1 of 1

LVGL ESP32 Background colour for lv_label

Posted: Sun Jan 02, 2022 4:47 am
by ESPCrazy
trying to change the background colour of the label
not sure what is wrong here

  1. lv_obj_t *headingLabel = lv_label_create(active_screen, NULL);
  2.  
  3.     lv_label_set_text(headingLabel, "Heading"); /*Set the labels text*/
  4.  
  5.     lv_obj_set_pos(headingLabel, lv_obj_get_width(list1), 0);
  6.     lv_obj_align(headingLabel, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
  7.     lv_obj_set_style_local_text_color(headingLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
  8. // set background colour of label
  9.    lv_obj_set_style_local_bg_color(headingLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_PURPLE);
  10.     lv_obj_set_style_local_text_font(headingLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_montserrat_42);
  11.  

Re: LVGL ESP32 Background colour for lv_label

Posted: Sun Jan 02, 2022 5:52 am
by Baldhead
Not the right place to ask.

Try lvgl forum page.

https://forum.lvgl.io/

Re: LVGL ESP32 Background colour for lv_label

Posted: Wed Jan 05, 2022 8:30 pm
by Jamawa
If I remember correctly, it is something like that the text background is not opaque by default. Try setting the opacity to full, otherwise you’re indeed far more likely to get a response on the LVGL forum