Stop automatic window resizing

Description

My problem is that i have an object that is supposed to fill the whole screen, but when it gets close to the edge of the display the window gets resized. If I apply the “fix” it creates some other weird changes(see screenshots). I hope I haven’t missed anything crucial or somethign stupid I have done, if so im very sorry. I would be grateful for any help.

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

For development purposes im just using the simulator.

What LVGL version are you using?

I’m currently using LVGL version 7.3.1

What do you want to achieve?

I would just like to know what causes this issue and how I could make an actual fix.

What have you tried so far?

I’ve tried all I could think of, and looked into the different lv_… c files without any luck.
I have noticed that there is already one post regarding this issue but I couldn’t get the suggestions to work.
If i use:

lv_page_set_scrollable_fit(lv_win_get_content(my_window), LV_FIT_NONE);

I get a weird layout change(see screenshots)

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.

I have included what I think is all the relevant code.

Note that this is including the “fix”:

lv_page_set_scrollable_fit(lv_win_get_content(my_window), LV_FIT_NONE);

And i have kept styles and other stuff even though I dont think its the “culprit”.
I’m sorry if i have missed something.

//screen size is 240 x 320 

lv_obj_t* winWifi = NULL;
lv_obj_t* CloseBtnWifi = NULL;
lv_obj_t* WifiHeaderImg = NULL;
lv_obj_t* WifiHeaderLabel = NULL;
lv_obj_t* WifiList = NULL;
lv_obj_t* WifiBox = NULL;
lv_obj_t* WifiBox_background = NULL;
lv_obj_t* pwd_ta = NULL;

void WifiWin(void)
{
    //Create style(s)
    static lv_style_t style_header_text;
    lv_style_init(&style_header_text);
    lv_style_set_text_color         (&style_header_text, LV_STATE_DEFAULT, LV_COLOR_BLACK);                                  //Text color

    static lv_style_t style_text;
    lv_style_init(&style_text);
    lv_style_set_text_color         (&style_text, LV_STATE_DEFAULT, LV_COLOR_BLACK);                                  //Text color
    lv_style_set_text_font          (&style_text, LV_STATE_DEFAULT, &Tahoma_14);                                       //Text font

    static lv_style_t style_list;
    lv_style_init(&style_list);
    lv_style_set_transition_time    (&style_list, LV_STATE_PRESSED, 0);
    lv_style_set_transition_time    (&style_list, LV_STATE_DEFAULT, 0);
    lv_style_set_transition_delay   (&style_list, LV_STATE_DEFAULT, 0);
    lv_style_set_transition_delay   (&style_list, LV_STATE_DEFAULT, 0);
    lv_style_set_image_recolor      (&style_list, LV_STATE_DEFAULT, LV_COLOR_WHITE);                                               //Symbol, text or image color
    lv_style_set_border_width       (&style_list, LV_STATE_DEFAULT, 2);                                                            
    lv_style_set_outline_width      (&style_list, LV_STATE_DEFAULT, 0);
    lv_style_set_outline_width      (&style_list, LV_STATE_PRESSED, 0);      
    lv_style_set_outline_width      (&style_list, LV_STATE_FOCUSED, 0);
    lv_style_set_border_color       (&style_list, LV_STATE_DEFAULT, LV_COLOR_MAKE(0xC4, 0xC4, 0xC4));                              //Border color
    lv_style_set_border_color       (&style_list, LV_STATE_PRESSED, LV_COLOR_MAKE(0xC4, 0xC4, 0xC4));                              //Border color
    lv_style_set_border_color       (&style_list, LV_STATE_FOCUSED, LV_COLOR_MAKE(0xC4, 0xC4, 0xC4));                              //Border color


    /*Create a window*/
    winWifi = lv_win_create(lv_scr_act(), NULL);
    lv_win_set_title                (winWifi, "");                        //Set the title
    lv_page_set_scrollable_fit(lv_win_get_content(winWifi), LV_FIT_NONE);   
    lv_win_set_btn_width            (winWifi, 0);
    lv_obj_add_style                (winWifi, LV_WIN_PART_BG, &style_win_bg);
    lv_obj_add_style                (winWifi, LV_WIN_PART_HEADER, &style_win_header);
    lv_win_set_header_height        (winWifi, 0);
    lv_obj_set_size                 (winWifi,240,320);
    lv_obj_align                    (winWifi,NULL,LV_ALIGN_CENTER,0,0);  
    printf("hor = %u ver = %u", lv_obj_get_width(winWifi),lv_obj_get_height(winWifi));

    CloseBtnWifi = lv_imgbtn_create(winWifi, NULL);           /*Add close button and use built-in close action*/
    lv_obj_set_event_cb             (CloseBtnWifi, close_window);
    lv_obj_add_style                (CloseBtnWifi, LV_BTN_PART_MAIN, &style_symbol);
    lv_imgbtn_set_src               (CloseBtnWifi, LV_BTN_STATE_PRESSED, &LV_SYMBOL_CLOSE);
    lv_imgbtn_set_src               (CloseBtnWifi, LV_BTN_STATE_RELEASED, &LV_SYMBOL_CLOSE);
    lv_obj_set_size                 (CloseBtnWifi, 20,20);
    lv_obj_set_pos                  (CloseBtnWifi, 210, 15);
    lv_obj_set_ext_click_area       (CloseBtnWifi, 3, 3, 3, 3);

    lv_obj_t* WifiHeaderImg = lv_img_create(winWifi, NULL);
    lv_img_set_src  (WifiHeaderImg, &LV_SYMBOL_WIFI);
    lv_obj_align    (WifiHeaderImg, NULL, LV_ALIGN_IN_TOP_MID, 0, 43);

    lv_obj_t* WifiHeaderLabel = lv_label_create(winWifi, NULL);
    lv_label_set_recolor            (WifiHeaderLabel, true);
    lv_label_set_text_fmt           (WifiHeaderLabel, "#000000 Wifi#");
    lv_obj_add_style                (WifiHeaderLabel, LV_LABEL_PART_MAIN, &style_header_text);
    lv_obj_align                    (WifiHeaderLabel, winSupport, LV_ALIGN_IN_TOP_MID, 0, 15);
    lv_label_set_align              (WifiHeaderLabel, LV_LABEL_ALIGN_CENTER);


    /*Create a list*/
    WifiList = lv_list_create(winWifi, NULL);
    lv_obj_add_style                (WifiList, LV_LIST_PART_BG, &style_list);
    lv_obj_set_size                 (WifiList, 180, 210);
    lv_obj_align                    (WifiList, NULL, LV_ALIGN_CENTER, 0, 25);
    lv_list_set_scroll_propagation  (WifiList, false);
    

    /*Add buttons to the list*/
    lv_obj_t * list_btn;

    char str[80];
    bool first = true;

    while (APList(str,80,first)) {
        char tmp[128];

        sprintf(tmp,"%s",str);

        list_btn = lv_list_add_btn  (WifiList, NULL ,tmp);
        lv_obj_set_event_cb(list_btn, list_handler);
        lv_obj_add_style(list_btn, LV_OBJ_PART_MAIN, &style_list);
        first = false;
    } // endwhile
   
    lv_obj_t* Logo = lv_img_create(winWifi, NULL);
    lv_img_set_src(Logo, &UmoverLogo);
    lv_obj_align(Logo, NULL, LV_ALIGN_CENTER, 0, 144);
}

static void list_handler(lv_obj_t * obj, lv_event_t event)
{

    if (obj == NULL) return;
    if (event != LV_EVENT_CLICKED) return;
    static const char * btns[] ={ "Close", ""};

    lv_style_init(&style_kb_text);
    lv_style_set_border_width       (&style_kb_text, LV_STATE_DEFAULT, 1);
    lv_style_set_outline_width      (&style_kb_text, LV_STATE_DEFAULT, 0);
    lv_style_set_outline_width      (&style_kb_text, LV_STATE_PRESSED, 0);
    lv_style_set_outline_width      (&style_kb_text, LV_STATE_FOCUSED, 0);
    lv_style_set_border_color       (&style_kb_text, LV_STATE_FOCUSED, lv_color_hex(0xdbdbdb));
    lv_style_set_border_color       (&style_kb_text, LV_STATE_DEFAULT, lv_color_hex(0xdbdbdb));
    lv_style_set_border_color       (&style_kb_text, LV_STATE_PRESSED, lv_color_hex(0xdbdbdb));
    lv_style_set_transition_time    (&style_kb_text, LV_STATE_PRESSED, 0);
    lv_style_set_transition_time    (&style_kb_text, LV_STATE_DEFAULT, 0);
    lv_style_set_transition_delay   (&style_kb_text, LV_STATE_PRESSED, 0);
    lv_style_set_transition_delay   (&style_kb_text, LV_STATE_DEFAULT, 0);

    WifiBox_background = lv_obj_create(winWifi,NULL);
    lv_obj_reset_style_list         (WifiBox_background, LV_OBJ_PART_MAIN);
    lv_obj_add_style                (WifiBox_background, LV_OBJ_PART_MAIN, &style_modal);
    //lv_obj_set_style_local_bg_opa   (WifiBox_background, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
    lv_obj_align                    (WifiBox_background, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
    lv_obj_set_size                 (WifiBox_background, hres, vres);
    lv_obj_set_event_cb             (WifiBox_background, msgbox_event_handler);

    WifiBox = lv_msgbox_create(winWifi, NULL);
    lv_msgbox_set_text(WifiBox, lv_list_get_btn_text(obj));
    lv_obj_align(WifiBox, NULL, LV_ALIGN_IN_TOP_MID,0 ,0);

     /* Create the password box */
    pwd_ta = lv_textarea_create(WifiBox, NULL);
    lv_textarea_set_text(pwd_ta, "");
    lv_textarea_set_pwd_mode(pwd_ta, true);
    lv_textarea_set_one_line(pwd_ta, true);
    lv_textarea_set_cursor_hidden(pwd_ta, true);
    lv_obj_set_width(pwd_ta, LV_HOR_RES / 2 - 20);
    lv_obj_set_pos(pwd_ta, 5, 20);
    //lv_obj_set_event_cb(pwd_ta, ta_event_cb);
    lv_obj_add_style(pwd_ta, LV_TEXTAREA_PART_BG, &style_kb_text);
    lv_obj_set_style_local_text_font(pwd_ta, LV_TEXTAREA_PART_BG, LV_STATE_DEFAULT, &Times_New_Roman_Bold_14);

    /* Create a label and position it above the text box */
    lv_obj_t * pwd_label = lv_label_create(WifiBox, NULL);
    lv_label_set_text(pwd_label, "Password:");
    lv_obj_align(pwd_label, pwd_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0);

    

    lv_msgbox_add_btns(WifiBox, btns);
    lv_obj_set_width(WifiBox, 180);
    //lv_obj_set_event_cb(WifiBox, msgbox_event_handler);
    lv_obj_align(WifiBox, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/

        if(event == LV_EVENT_CLICKED) {
        printf("Clicked: %s\n", lv_list_get_btn_text(obj));
        lv_list_focus_btn(WifiList, NULL);
    }
}

static void msgbox_event_handler(lv_obj_t * obj, lv_event_t event) {
    if (event == LV_EVENT_VALUE_CHANGED) {
        printf("msgbox_value_changed\n");
        lv_obj_del(DelBtn);
        lv_obj_del(WifiKeyboard); //This is the keyboard assigned to pwd_ta
        lv_obj_del(WifiBox);
        WifiKeyboard = NULL;
    }
    if (obj == WifiBox_background && event == LV_EVENT_CLICKED) {
        printf("delete\n");
        lv_obj_del(WifiBox_background);
        lv_obj_del(WifiBox);
        printf("done delete\n");
        if (WifiKeyboard != NULL) {
            lv_obj_del(WifiKeyboard);
        }
    }
}

Screenshot and/or video

Before adding:

lv_page_set_scrollable_fit(lv_win_get_content(my_window), LV_FIT_NONE);

And with the annoying resizing
Screenshot 2020-09-18 20.51.10
After adding:

lv_page_set_scrollable_fit(lv_win_get_content(my_window), LV_FIT_NONE);

And apperently without the annoying resizing, but this weird cut of the logo at the bottom, and other layout changes
Screenshot 2020-09-18 20.51.34

Has anyone got a solution? Because im very confused as to why its cutting of the bottom of my screen

Okay, I have been playing around with this and realised that im just a bit of moron.
It was the placement of the line:

lv_page_set_scrollable_fit(lv_win_get_content(winWifi), LV_FIT_NONE);

that was the problem. When I moved it to be the last line it all worked out fine. Sorry for the hassle, and keep up the good work btw.