Description
I wish to change ButtonMatrix- background’s color to transparent color ,
but when config by LV_COLOR_TRANSP , it shows green instead.
What MCU/Processor/Board and compiler are you using?
- ESP32
What do you want to achieve?
ButtonMatrix- background’s color to transparent color.
What have you tried so far?
Code to reproduce
static const char * btnm_map[] = {"1", "2", "3", "4", "5", "\n",
"6", "7", "8", "9", "10", "\n",
"11", "12", "13", "14", "15", "\n",
"16", "17", "18", "19", "20", ""
};
void create_ButtonMatrix() {
lv_obj_t * btnm1 = lv_btnm_create(lv_scr_act(), NULL);
lv_obj_set_size(btnm1, 320,240);
/* style should set before map */
static lv_style_t style_bg;
lv_style_copy(&style_bg , lv_btnm_get_style(btnm1, LV_BTNM_STYLE_BG));
lv_btnm_set_style(btnm1, LV_BTNM_STYLE_BG, &style_bg);
uint8_t padding = 10;
style_bg.body.padding.inner = padding;
style_bg.body.padding.bottom = padding;
style_bg.body.padding.left = padding;
style_bg.body.padding.right = padding;
style_bg.body.padding.top = padding;
style_bg.body.main_color = LV_COLOR_TRANSP; //LV_COLOR_RED;
style_bg.body.grad_color = LV_COLOR_TRANSP; //LV_COLOR_RED;
/* mapping */
lv_btnm_set_map(btnm1, btnm_map);
lv_obj_align(btnm1, NULL, LV_ALIGN_CENTER, 0,0);
lv_obj_set_event_cb(btnm1, [](lv_obj_t *obj, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
const char* txt = lv_btnm_get_active_btn_text(obj);
if(txt != NULL) Serial.printf("%s was pressed\n",txt );
}
});
}