Description
I am creating a custom menu which will ultimately contain controls within each item (so they are a bit more than just a list of labels). For this I am using a container with the alignment set to LV_LAYOUT_COL_M and then I add my custom obj items. However there is spacing/padding between each item which I do not want.
I’m believe this is something to do with the style but nothing I have tried as worked.
What MCU/Processor/Board and compiler are you using?
Visual Studio simulation. LittleVgl6.0
What do you want to achieve?
Aligned objects without spacing between them (see screenshot below).
What have you tried so far?
See code below. I have tried changing the body.padding to top and bottom but made no difference.
Code to reproduce
static lv_style_t titlestyle;
static lv_style_t helpstyle;
static void CreateNewMenu()
{
// Base container ************************************
lv_obj_t* base = lv_list_create(lv_scr_act(), NULL);
lv_obj_set_size(base, 800, 400);
lv_cont_set_layout(base, LV_LAYOUT_COL_M);
// Setup styles ************************************
lv_style_copy(&titlestyle, &lv_style_plain);
lv_style_copy(&helpstyle, &lv_style_plain);
titlestyle.text.color = LV_COLOR_WHITE;
titlestyle.text.font = &lv_font_roboto_28;
titlestyle.body.main_color = lv_color_hex(0x134b8e);
titlestyle.body.grad_color = lv_color_hex(0x134b8e);
//titlestyle.body.padding.bottom = 0;
//titlestyle.body.padding.top = 0;
helpstyle.text.color = LV_COLOR_CYAN;
helpstyle.text.font = &lv_font_roboto_12;
// Creating menu items ************************************
CreateMenuItem(base, "Item1");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
CreateMenuItem(base, "Item2");
}
static void CreateMenuItem(lv_obj_t* parent, char * titleText)
{
lv_obj_t* base = lv_obj_create(parent, NULL);
lv_obj_set_size(base, 800, 50);
lv_obj_set_style(base, &titlestyle);
lv_obj_t* title = lv_label_create(base, NULL);
lv_label_set_text(title, titleText);
lv_obj_set_pos(title, 10, 2);
lv_obj_set_style(title, &titlestyle);
}
Screenshot and/or video
I want to remove the white space between each item. Simply changing the parents background colour to match the items is not suitable for my use.