Hello developers team
I have read this report,
opened 08:48AM - 20 Feb 24 UTC
closed 01:09PM - 22 Feb 24 UTC
### LVGL version
V9.0.0
### What happened?
I try to use the image butto… n in V9 but the provided example does not produce any output.
Even on the document page the example is just empty:
[https://docs.lvgl.io/master/widgets/imagebutton.html#example](https://docs.lvgl.io/master/widgets/imagebutton.html#example)
The example images are included in the project and the project just compiles fine (VS simulator). There's no problem to show the example button images on an image widget but it does not work on an image button.
### How to reproduce?
```
#include "../../lv_examples.h"
void lv_example_imagebutton_1(void)
{
LV_IMAGE_DECLARE(imagebutton_left);
LV_IMAGE_DECLARE(imagebutton_right);
LV_IMAGE_DECLARE(imagebutton_mid);
/*Create a transition animation on width transformation and recolor.*/
static lv_style_prop_t tr_prop[] = {LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_IMAGE_RECOLOR_OPA, 0};
static lv_style_transition_dsc_t tr;
lv_style_transition_dsc_init(&tr, tr_prop, lv_anim_path_linear, 200, 0, NULL);
static lv_style_t style_def;
lv_style_init(&style_def);
lv_style_set_text_color(&style_def, lv_color_white());
lv_style_set_transition(&style_def, &tr);
/*Darken the button when pressed and make it wider*/
static lv_style_t style_pr;
lv_style_init(&style_pr);
lv_style_set_image_recolor_opa(&style_pr, LV_OPA_30);
lv_style_set_image_recolor(&style_pr, lv_color_black());
lv_style_set_transform_width(&style_pr, 20);
/*Create an image button*/
lv_obj_t * imagebutton1 = lv_imagebutton_create(lv_screen_active());
lv_imagebutton_set_src(imagebutton1, LV_IMAGEBUTTON_STATE_RELEASED, &imagebutton_left, &imagebutton_mid,
&imagebutton_right);
lv_obj_add_style(imagebutton1, &style_def, 0);
lv_obj_add_style(imagebutton1, &style_pr, LV_STATE_PRESSED);
lv_obj_align(imagebutton1, LV_ALIGN_CENTER, 0, 0);
/*Create a label on the image button*/
lv_obj_t * label = lv_label_create(imagebutton1);
lv_label_set_text(label, "Button");
lv_obj_align(label, LV_ALIGN_CENTER, 0, -4);
}
```
but it seems it’s still a problem in V9.1. I have used other features like graph, label, simple button from example folder, but image button still doesn’t work. even with setting width.
YuryIce
February 19, 2025, 9:15am
4
How did you solve the problem? What was the cause of it? I’m trying to get my UI work in simulator (VS2017) and imagebutton example doesnt work. Animation not showing at all, but calback event working. I absolutely have no idea how to solve this. (I assume that problem somehow related to image creation that im trying to use, wrong parent may be?).
YuryIce
February 19, 2025, 10:38am
5
This is all just documentation misunderstanding, do not create additional images for imagebutton.
lv_imagebutton_set_src accept direct image path not image itself.