How to Force lv_win Page Size so to Avoid Scrolling when Window is Resized?

What LVGL version are you using?

Master

What do you want to achieve?

Resize lv_win object and also have its page be the same size as the window content, so its children can be realigned to the new size to fit in the window, without it turning into a scrolling page.

What have you tried so far?

lv_win_set_content_size, didn’t seem to resize the page’s container and I could not realign the children to the new window.

rn I’m using a workaround that lv_obj_align the children to the lv_win object itself instead of letting it use its parent (aka the lv_page inside the win)

I do want to know the proper way to do this though.

As far as I know, calling the normal lv_obj_set_size on the window will make it resize its content area as well.

not sure why it’s putting my obj off screen and requires scrolling when I made the lv_win smaller. (cuz it looks like to me lv_obj_set_size also applies on the page inside…)
btw, the child is set to LV_ALIGN_IN_BOTTOM_MID. Does it have something to do with how lv_page scrolling works? Does it default to scrolling instead of making the page content smaller?

By default the page will become scrollable if the child object is larger than it. lv_page_set_scrollable_fit(lv_win_get_content(win), LV_FIT_NONE); should prevent that behavior.

hmmm, tried that, no luck

Please send a code snippet to reproduce.

lv_obj_t* screenObj = lv_obj_create(NULL, NULL);
lv_obj_set_size(screenObj, 448, 512);

lv_obj_t* win = lv_win_create(screenObj, NULL);

lv_obj_t* btn = lv_btn_create(
    win, NULL);  // add a random obj (btn) to the window to show the issue
lv_obj_align(btn, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -50);

lv_scr_load(screenObj);

lv_obj_set_size(screenObj, 320,
                384);  // at some point, screen size needs to be changed
lv_obj_set_size(
    win, 320,
    384);  // changing the screen size doesn't seem to change the win size,
           // so I tried to manually set it to fit in the new screen size,
           // but the button position doesn't seem to get changed with this

The problem is that you can’t set the size of the screen directly.

Try this

  lv_obj_t* screenObj = lv_obj_create(lv_scr_act(), NULL);
  lv_obj_set_size(screenObj, 448, 512);

  lv_obj_t* win = lv_win_create(screenObj, NULL);

  lv_obj_t* btn = lv_btn_create(
      win, NULL);  // add a random obj (btn) to the window to show the issue
  lv_obj_align(btn, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -50);


  lv_obj_set_size(screenObj, 320,
                  384);  // at some point, screen size needs to be changed
  lv_obj_set_size(
      win, 320,
      384);  // changing the screen size doesn't seem to change the win size,
             // so I tried to manually set it to fit in the new screen size,
             // but the button position doesn't seem to get changed with this