How to set size of Button (lv_btn) in pixel unit?



I would like to set the size of three button on full screen.

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


What do you want to achieve?

I would like to set three big buttons using pixel unit if possible.

What have you tried so far?

Code below.

Code to reproduce

static void create( )
    lv_coord_t hres = lv_disp_get_hor_res(NULL);    
    lv_obj_t * wp = lv_img_create(lv_disp_get_scr_act(NULL), NULL);    
    lv_img_set_src(wp, &img_bubble_test);    
    lv_obj_set_width(wp, hres);
    lv_obj_set_protect(wp, LV_PROTECT_POS);

// button 1		
// btn1 variable are global.
    btn1 = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_set_event_cb(btn1, event_handler_btn1);
    lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -160);
    lv_btn_set_toggle(btn1, true);

    // lv_btn_set_fit2(btn1, LV_FIT_NONE, LV_FIT_TIGHT);
    label1 = lv_label_create(btn1, NULL);
    lv_label_set_text(label1, "BTN1");   

    lv_btn_set_ink_in_time(btn1, 1000);

    lv_btn_set_ink_wait_time(btn1, 100);

    lv_btn_set_ink_out_time(btn1, 100);

    my_label = lv_label_create(lv_scr_act(), NULL);
    lv_obj_set_width(my_label, 100);

    char buf1[32];
    snprintf(buf1, 32, "%d", bt1Time);
    lv_label_set_text(my_label, buf1);
    lv_obj_align(my_label, NULL, LV_ALIGN_CENTER, 100, -80);

// button 2

    lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_set_event_cb(btn2, event_handler_btn2);
    lv_obj_align(btn2, NULL, LV_ALIGN_CENTER, 0, 0);
    lv_btn_set_toggle(btn2, true);
    // lv_btn_set_fit2(btn2, LV_FIT_NONE, LV_FIT_TIGHT);

    label2 = lv_label_create(btn2, NULL);
    lv_label_set_text(label2, "BTN2");

// button 3

    lv_obj_t * btn3 = lv_btn_create(lv_scr_act(), NULL);
    lv_obj_set_event_cb(btn3, event_handler_btn3);
    lv_obj_align(btn3, NULL, LV_ALIGN_CENTER, 0, 160);
    lv_btn_set_toggle(btn3, true);
    // lv_btn_set_fit2(btn3, LV_FIT_NONE, LV_FIT_TIGHT);

    label3 = lv_label_create(btn3, NULL);
    lv_label_set_text(label3, "BTN3");

    lv_obj_set_opa_scale_enable(btn3, true);
    lv_obj_set_opa_scale(btn3, 178);


You use lv_obj_set_size. This is mentioned in the documentation.


I read the documentation a long time ago.

I consulted only the documentation of the button object.