Description
I am trying to make a list on a small monochrome screen.
What MCU/Processor/Board and compiler are you using?
Simulator on Visual Studio
What do you want to achieve?
Remove the space between buttons. Marked in red here.
What have you tried so far?
I tried different padding in many of the styles possible in list. I also tried using lv_obj_set_size()
. None of them remove the spaces.
Code to reproduce
lv_theme_t * th = lv_theme_mono_init(210, NULL);
lv_theme_set_current(th);
/*Create a list*/
lv_obj_t * list1 = lv_list_create(lv_scr_act(), NULL);
lv_obj_set_size(list1, LV_HOR_RES_MAX, LV_VER_RES_MAX);
lv_obj_align(list1, NULL, LV_ALIGN_CENTER, 0, 0);
g = lv_group_create();
lv_indev_set_group(kp_indev, g);
lv_group_set_style_mod_cb(g, my_style_mod_cb);
lv_group_add_obj(g, list1);
const char * list_txts[] = { "File 1", "File 2", "File 3", "File 4", "File 5", "File 6", "" };
uint32_t i;
for (i = 0; list_txts[i][0] != '\0'; i++) {
lv_obj_t * b;
b = lv_list_add_btn(list1, NULL, list_txts[i]);
lv_obj_set_event_cb(b, event_handler);
}
/*Set style*/
static lv_style_t styleBG;
lv_style_copy(&styleBG, th->style.list.bg);
styleBG.body.border.width = 0;
styleBG.body.padding.top = 0;
styleBG.body.padding.bottom = 0;
styleBG.body.padding.left = 5;
styleBG.body.padding.right = 5;
lv_list_set_style(list1, LV_LIST_STYLE_BG, &styleBG);
static lv_style_t styleBtnREL;
lv_style_copy(&styleBtnREL, th->style.list.btn.rel);
styleBtnREL.body.padding.top = 3;
styleBtnREL.body.padding.bottom = 3;
lv_list_set_style(list1, LV_LIST_STYLE_BTN_REL, &styleBtnREL);
static lv_style_t styleBtnPR;
lv_style_copy(&styleBtnPR, th->style.list.btn.pr);
styleBtnPR.body.padding.top = 3;
styleBtnPR.body.padding.bottom = 3;
lv_list_set_style(list1, LV_LIST_STYLE_BTN_PR, &styleBtnPR);
static lv_style_t styleBtnTGLREL;
lv_style_copy(&styleBtnTGLREL, th->style.list.btn.tgl_rel);
styleBtnTGLREL.body.padding.top = 3;
styleBtnTGLREL.body.padding.bottom = 3;
lv_list_set_style(list1, LV_LIST_STYLE_BTN_TGL_REL, &styleBtnTGLREL);
static lv_style_t styleBtnTGLPR;
lv_style_copy(&styleBtnTGLPR, th->style.list.btn.tgl_pr);
styleBtnTGLPR.body.padding.top = 3;
styleBtnTGLPR.body.padding.bottom = 3;
lv_list_set_style(list1, LV_LIST_STYLE_BTN_TGL_PR, &styleBtnTGLPR);
static lv_style_t styleBtnINA;
lv_style_copy(&styleBtnINA, th->style.list.btn.ina);
styleBtnINA.body.padding.top = 3;
styleBtnINA.body.padding.bottom = 3;
lv_list_set_style(list1, LV_LIST_STYLE_BTN_INA, &styleBtnINA);