How to set size/position of checkboxes added as children to lv_list

I’m creating an list and then adding checkbox objects as its children. However, whenever I try to set the checkbox’s width, height, or X/Y position, nothing changes.

Platform:Linux.
LVGL Version : Wayland 7.1.0

My code snippet:
// Create list
lv_obj_t * list = lv_list_create(lv_scr_act());
lv_obj_set_size(list, 200, 300);
lv_list_set_layout(list,LV_LAYOUT_COLUMN_RIGHT);

// Create checkbox as a child of the list
lv_obj_t * cb = lv_checkbox_create(list);
lv_checkbox_set_text(cb, “Option 1”);

// Attempt to set size and position
lv_obj_set_size(cb, 120, 30);
lv_obj_set_pos(cb, 10, 15);

How can I set the width, height, and X/Y position of a checkbox (or any custom child) inside an list?

1 Like

list can use flex to layout its child elements, so to be able to change the position of the checkbox, I think you should make it a child element of the list’s child element

Object Visibility and Rendering Issue when Screen Transparency is enabled.

Setup:

  • LVGL version: 7.1 Wayland
  • LV_COLOR_SCREEN_TRANSP is set to 1 in lv_conf.h.
  • The screen’s opacity is set to LV_OPA_TRANSP.
  • The display opacity is set to LV_OPA_TRANSP with lv_disp_set_bg_opa(NULL, LV_OPA_TRANSP);

I’m encountering issues with object visibility toggling and partial rendering when screen transparency is enabled

Scenario:

I have a button that toggles the visibility of a list containing checkboxes. The list is aligned at the bottom-left of the button.

Code Example:

/* Create a button /
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_size(btn, 100, 50);
lv_obj_set_pos(btn,2,0)
lv_obj_set_event_cb(btn, btn_event_handler); /
Button event callback */

/* Create a list and align it */
lv_obj_t * list = lv_list_create(lv_scr_act(), NULL);
lv_obj_align(list, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);

/* Create checkboxes as children of the list */
lv_obj_t * chk1 = lv_checkbox_create(list, NULL);
lv_checkbox_set_text(chk1, “Checkbox 1”);

lv_obj_t * chk2 = lv_checkbox_create(list, NULL);
lv_checkbox_set_text(chk2, “Checkbox 2”);

lv_obj_t * chk3 = lv_checkbox_create(list, NULL);
lv_checkbox_set_text(chk3, “Checkbox 3”);

/* Event callback for button to toggle visibility of the list /
void btn_event_handler(lv_obj_t * obj, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
if (lv_obj_get_hidden(list)) {
lv_obj_set_hidden(list, false); /
Show the list /
} else {
lv_obj_set_hidden(list, true); /
Hide the list */
}
}
}

Issues:

1. Visibility Toggling Issue

  • I’m using lv_obj_get_hidden(list) and lv_obj_set_hidden(list, true/false) to toggle the visibility of the list.
  • The visibility toggling works correctly, but when screen transparency is enabled, the list doesn’t visually show or hide, even though the lv_obj_get_hidden(list) returns correct state.

2. Partial Rendering

  • Even when the list is visible, only parts of the child objects (like the checkbox bullet) are rendered. The checkbox labels and background are not rendered properly or appear invisible.
  • This issue only occurs when screen transparency is enabled. When transparency is disabled, everything works fine.

Verified that styles (background opacity, text opacity) are set to LV_OPA_COVER where needed.
Tried lv_obj_invalidate(screen) after toggling visibility to ensure proper redraw.