Description
I have some button that have icons(images) inside them. When they are pressed I would like to recolor the icons, like it is done for text
What MCU/Processor/Board and compiler are you using?
Simulator
What LVGL version are you using?
8.1 (master)
What do you want to achieve?
images in button gets recolored when button is pressed
What have you tried so far?
I have tried a simple example.
lv_obj_t * root = lv_obj_create(NULL);
lv_obj_t * button = lv_btn_create(root);
lv_obj_t * img = lv_img_create(button);
lv_img_set_src(img, &phone);
lv_obj_center(button);
lv_obj_center(img);
lv_style_t test;
lv_style_init(&test);
lv_style_set_img_recolor(&test, lv_color_hex3(0xF00));
lv_style_set_bg_color(&test, lv_color_hex(0x222));
lv_style_set_bg_opa(&test, 255);
lv_style_set_img_recolor_opa(&test, 255);
lv_obj_add_style(button, &test, LV_PART_MAIN | LV_STATE_PRESSED);
lv_scr_load(root);
I could create an event handler that does it manually, but that not what i want.