Whether the IMGBTN widgets has specific requirements for img size?

Hi, I use the IMGBTN widgets, but I only have one image source (no left, center, and right), I want to put it in the middle, but it repeats like the following :

.PNG original image :
music_collect

lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, NULL, &music_collect, NULL); 

1650008873(1)

I tried the same on the lv_example_imgbtn_1() with the following effect :

lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, NULL, &imgbtn_left, NULL); //&imgbtn_left, &imgbtn_mid, &imgbtn_right

lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, NULL, &imgbtn_mid, NULL); //&imgbtn_left, &imgbtn_mid, &imgbtn_right

How can I make the picture of the IMGBTN show only one and not repeat?Just like the original .PNG image

@kisvegabor

I have the same problem.
Lvgl8 cannot be implemented like lvgl7,Simple switching of two pictures.

The code is as follows:
lv_obj_t * imgbtn1 = lv_imgbtn_create(lv_scr_act());
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, NULL, &imgbtn_left, NULL);
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_PRESSED, NULL, &imgbtn_right, NULL);
lv_obj_align(imgbtn1, LV_ALIGN_CENTER, 0, 0);

For this you can use the bg_img_src style property.

Thank you for your reply。I still don’t know how to set the bg_img_src,But I found another way:set the obj size, lv_obj_set_size(imgbtn,img_x,img_y);

1 Like

hi
thanks so much it s works perfect