Placing controls in particular order

Hello,

Trying to understand the way of locating controls on the screen. I was trying to place buttons directly on tab t4 and on container h :

 static void main_window_create3()
{

	tv = lv_tabview_create(lv_scr_act(), NULL);
	lv_obj_set_event_cb(tv, tv_event_cb);
	t4 = lv_tabview_add_tab(tv, "***");
	lv_group_add_obj(g, tv);

	
	
	lv_obj_t* h = lv_cont_create(t4, NULL);
	lv_cont_set_layout(h, LV_LAYOUT_PRETTY_MID);
	lv_obj_set_drag_parent(h, true);
	lv_obj_set_style_local_value_str(h, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, "base");
	lv_cont_set_fit2(h, LV_FIT_TIGHT, LV_FIT_MAX);
	


	lv_obj_t* table = t4; // if use tabview
	//lv_obj_t* table = h;  // if use container

	lv_obj_t* b = lv_btn_create(table, NULL);
	lv_obj_t* l = lv_label_create(b, NULL);
	lv_label_set_text(l, "1");
	lv_btn_set_checkable(b, true);
	lv_btn_set_fit2(b, LV_FIT_TIGHT, LV_FIT_TIGHT);

	b = lv_btn_create(table, b);
	l = lv_label_create(b, NULL);
	lv_label_set_text(l, "2");


	b = lv_btn_create(table, b);
	l = lv_label_create(b, NULL);
	lv_label_set_text(l, "3");

	b = lv_btn_create(table, b);
	l = lv_label_create(b, NULL);
	lv_label_set_text(l, "4");


	b = lv_btn_create(table, b);
	l = lv_label_create(b, NULL);
	lv_label_set_text(l, "5");
}

In case I place buttons on container I see some nice order in which controls was placed:

In case I place directly on tab, I got all buttons placed on each other:
image

What is strategy of placing controls on the form in general?

Why container has ability to organize control not to cover each other an why tab don’t have it?

Is it possible to define rules for container regarding vertical and horizontal spacing?

In case I prefer to place controls on tab I need to provide coordinates for each button? Is that only strategy to achieve that?

If a container with a layout is in use, it tries to position and resize the objects automatically. Otherwise, the developer is responsible for setting the position and size themselves.

Tabs are pages, which by default do not have a layout applied. You can apply one with lv_page_set_scrl_layout(tab, LV_LAYOUT_COLUMN_LEFT), for example.