Setting button size does not take effect!

Description

Set the button’s layout first, then set the size and layout again, button’s size has not changed.

Code to reproduce

For example:

        static lv_style_t btnStyle;
        static lv_style_t labelStyle;
        lv_style_init(&btnStyle);
        lv_style_init(&labelStyle);

        //button style
        lv_style_set_border_width(&btnStyle, LV_STATE_DEFAULT, 1);
        lv_style_set_border_color(&btnStyle, LV_STATE_DEFAULT, LV_COLOR_RED);
        lv_style_set_border_opa(&btnStyle, LV_STATE_DEFAULT, LV_OPA_COVER);

        //label style
        lv_style_set_text_opa(&labelStyle, LV_STATE_DEFAULT, LV_OPA_COVER);

        lv_obj_t* cont = lv_cont_create(lv_scr_act(), nullptr);
        lv_cont_set_layout(cont, LV_LAYOUT_ROW_MID);
        lv_cont_set_fit2(cont, LV_FIT_TIGHT, LV_FIT_TIGHT);

        lv_obj_t* btn = lv_btn_create(cont, nullptr);
        lv_obj_reset_style_list(btn, LV_BTN_PART_MAIN);
        lv_btn_set_fit(btn, LV_FIT_TIGHT);
        lv_btn_set_layout(btn, LV_LAYOUT_OFF);

        lv_obj_t* label = lv_label_create(btn, nullptr);
        lv_label_set_text(label, "text");
        lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);

        lv_obj_set_size(btn, 100, 100);

        lv_btn_set_fit(btn, LV_FIT_NONE);
        lv_btn_set_layout(btn, LV_LAYOUT_CENTER);

        lv_obj_add_style(btn, LV_BTN_PART_MAIN, &btnStyle);
        lv_obj_add_style(label, LV_LABEL_PART_MAIN, &labelStyle);

        lv_obj_align(cont, nullptr, LV_ALIGN_CENTER, 0, 0);

Version

V7.1.0

I think you may need to turn off the fit feature on the button before setting the size, as it controls how the button is sized.

Right now you’re calling lv_obj_set_size before lv_btn_set_fit, instead of the other way around.