What is the solution to the problem that the image button disappears when animated?

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


What MCU/Processor/Board and compiler are you using?

Visual studio simulator

What LVGL version are you using?


What do you want to achieve?

When I click the button, the button is displayed as a white box during animation. (see attached picture)
How do I make the image button visible while the screen change animation is running?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/
    screen1 = lv_obj_create(NULL, NULL);
    screen2 = lv_obj_create(NULL, NULL);
    btn_chart = lv_imgbtn_create(screen1, NULL);
    lv_obj_align(btn_chart, screen1, LV_ALIGN_IN_TOP_LEFT, 10, 10);
    lv_imgbtn_set_src(btn_chart, LV_BTN_STATE_RELEASED, &icon_chart);
    lv_imgbtn_set_src(btn_chart, LV_BTN_STATE_PRESSED, &icon_chart);
    lv_obj_set_event_cb(btn_chart, cb_button_event);   // Assign an event callback

   button event is below
    if ((ob == btn_chart) && (ev == LV_EVENT_CLICKED))
        printf("chart btn clicked\n\r");
        lv_scr_load_anim(screen2, LV_SCR_LOAD_ANIM_OVER_LEFT, 1000, 0, false);


Screenshot and/or video

If possible, add screenshots and/or videos about the current state.


It happens because you use both lv_scr_load_anim and lv_scr_load and messes up screen loading.

Just remove lv_scr_load(screen2); from the event.

Thanks for the reply. resolved.