How to change order of childs in a parent?


Assuming, we have one parent containing multiple childs and the childs overlap.

Is there any way to change the order oft the childs, to “raise” one of them onto the “top”? That is, the one which was raised becomes visible completely.


There are several functions that will let you change the relative order of objects.
Check out the Layers documentation:

Bring to the foreground

There are four explicit ways to bring an object to the foreground:

  • Use lv_obj_move_foreground(obj) to bring an object to the foreground. Similarly, use lv_obj_move_background(obj) to move it to the background.
  • Use lv_obj_move_up(obj) to move an object one position up in the hierarchy, Similarly, use lv_obj_move_down(obj) to move an object one position down in the hierarchy.
  • Use lv_obj_swap(obj1, obj2) to swap the relative layer position of two objects.
  • When lv_obj_set_parent(obj, new_parent) is used, obj will be on the foreground of the new_parent.
1 Like