How to set height of a messageBox


I want to set a smaller height for a messageBox but I can’t find how to do, it is possible? Thanks in advace

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

ESP32 with ILI9341 and Arduino IDE

What LVGL version are you using?


What do you want to achieve?

Set the height smaller of a messageBox because it doesn’t fit in my screen

What have you tried so far?

lv_obj_set_height(mbox_connect, 100);

but it doesn’t work and I can’t find nothing in the documentation

Code to reproduce

 mbox_connect = lv_msgbox_create(lv_scr_act(), NULL);
  static const char * btns[] ={"Conectar", "Cancelar", ""};
  ta_password = lv_textarea_create(mbox_connect, NULL);
  lv_obj_set_size(ta_password, 100, 30);
  lv_textarea_set_text(ta_password, "");
  lv_obj_add_style(mbox_connect, LV_OBJ_PART_MAIN, &smallFont);

  lv_msgbox_add_btns(mbox_connect, btns);
  lv_obj_set_width(mbox_connect, 200);
  lv_obj_set_height(mbox_connect, 100);
  lv_obj_set_event_cb(mbox_connect, mbox_event_handler);
  lv_obj_align(mbox_connect, NULL, LV_ALIGN_CENTER, 0, -60);

Screenshot and/or video


The height is calculated automatically from the size of the items and paddings.
Try setting smaller paddings like:

    lv_obj_set_style_local_pad_inner(mbox_connect, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 3);
    lv_obj_set_style_local_pad_top(mbox_connect, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 3);
    lv_obj_set_style_local_pad_bottom(mbox_connect, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 3);

It works perfect thanks a lot for all