How to add padding to object


I have a number of objects on a tabview, I would like to pad the last one so it doesnt butt up against my footer.

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


What LVGL version are you using?


What do you want to achieve?

Per description

What have you tried so far?

Padding the object but thats for the inner components

Code to reproduce

lv_obj_t * createPage(lv_obj_t * parent, int x, int y, char* title)
    /*Create a page*/
    lv_obj_t * page = lv_obj_create(parent);

    lv_obj_set_size(page, 330, 225);
	lv_obj_align_to(page, parent, LV_ALIGN_TOP_LEFT, x, y);

    lv_obj_set_style_pad_top(page, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_bottom(page, 10, LV_PART_MAIN);
    lv_obj_set_style_pad_left(page, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_right(page, 0, LV_PART_MAIN);

    /*Create a label on the page*/
    lv_obj_t * label = lv_label_create(page);
    lv_label_set_text(label, title);
	lv_obj_align_to(label, page, LV_ALIGN_TOP_MID, 0, 5);

    lv_obj_set_style_pad_top(label, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_bottom(label, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_left(label, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_right(label, 0, LV_PART_MAIN);

    return page;

Screenshot and/or video

@bader looks like I’m asking you for a lot… You’re so helpful how can I not?

No problem, I am glad I can help.

Mmmm I don’t know, try to increase the padding (bottom) to the Lights tap.

That didnt work.

I tried:

    lv_obj_set_style_pad_bottom(page, 20, LV_PART_MAIN);

But it didnt make any difference…

Any other suggestions?

Thanks in advance!

Apply it to the parent of the page (the lights tab object inside the tabview) not the page itself.

1 Like


That just bloody worked!!

How on earth did you know that??

Thank you!