Description
Hi, I want to change lv_win header,Including color, transparency…
What MCU/Processor/Board and compiler are you using?
STM32
What do you want to achieve?
I’m going to change the lv_win header color and the transparency
What have you tried so far?
I’ve tried using these interfaces, lv_obj_set_bg_opa/lv_style_set_border_color, but to no avail
Code to reproduce
static void lv_user_mainpage(void)
{
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x2f3243));
/*Create a window*/
lv_obj_t* win = lv_win_create(lv_scr_act(), NULL);
lv_win_set_title(win, "Window title"); /*Set the title*/
//lv_win_set_drag(win,true);
lv_win_set_scrollbar_mode(win, LV_SCROLLBAR_MODE_DRAG);
//lv_win_set_layout(win, LV_LAYOUT_CENTER);
//lv_obj_set_bg_opa(&win, LV_OBJ_PART_MAIN,LV_STATE_DEFAULT, LV_OPA_0);
lv_win_set_header_height(win, 50);
//lv_win_set_layout(win,50);
//_lv_obj_set_style_local_opa(win, LV_OBJ_PART_MAIN,LV_STYLE_BORDER_OPA | (LV_STATE_PRESSED << LV_STYLE_STATE_POS), LV_OPA_0);
/*Add control button to the header*/
lv_obj_t* close_btn = lv_win_add_btn(win, LV_SYMBOL_CLOSE); /*Add close button and use built-in close action*/
lv_obj_set_event_cb(close_btn, lv_win_close_event_cb);
lv_win_add_btn(win, LV_SYMBOL_SETTINGS); /*Add a setup button*/
/*Add some dummy content*/
lv_obj_t* txt = lv_label_create(win, NULL);
lv_label_set_text(txt, "This is the content of the window");
lv_obj_set_style_local_bg_color(close_btn, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x2f3243));
//lv_obj_set_style_local_bg_opa(win, LV_OBJ_PART_MAIN,LV_STATE_DEFAULT, LV_OPA_0);
//lv_obj_set_style_local_border_opa(win, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
static lv_style_t win_style;
lv_style_init(&win_style);
lv_style_set_bg_opa(&win_style, LV_STATE_DEFAULT, LV_OPA_0);
//lv_style_set_border_width(&win_style, LV_STATE_DEFAULT, 50);
//lv_style_set_border_color(&win_style, LV_STATE_DEFAULT, LV_COLOR_RED);
lv_style_set_text_color(&win_style, LV_STATE_DEFAULT, LV_COLOR_RED);
//lv_style_set_line_color(&win_style, LV_STATE_DEFAULT, lv_color_hex(0x4cb242));
//lv_style_set_image_opa(&win_style, LV_STATE_DEFAULT, LV_OPA_0);
//lv_style_set_pattern_image();
lv_obj_add_style(win, LV_LABEL_PART_MAIN, &win_style);
}
Screenshot and/or video
Summary
This text will be hidden