Hi,
I want to know if we create a menu page(main page or sub-page) and want to create several objects like button and label under that page, how to align them giving x and y co-ordinates ?
I could not find any ways to align child objects of the menu page .
Code snippet is given
Thank you .
Description
What MCU/Processor/Board and compiler are you using?
simulator, visual studio, windows
What LVGL version are you using?
8.3
What do you want to achieve?
Align a ‘label’ object of the menu page by giving x and y co-ordinates
What have you tried so far?
I wrote this code , but the label object is not getting aligned , instead of displaying center of the screen
it is getting displayed at top mid
lv_obj_t * label;
lv_obj_t * main_page = lv_menu_page_create(menu, NULL);
label = lv_label_create(main_page);
lv_label_set_text(label, "Item 1");
lv_obj_align(label, LV_ALIGN_CENTER, 0,0);
Code to reproduce
void lv_example_menu_1(void)
{
/*Create a menu object*/
lv_obj_t* menu = lv_menu_create(lv_scr_act());
lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
lv_obj_center(menu);
lv_menu_set_mode_header(menu, LV_MENU_HEADER_TOP_UNFIXED);
lv_menu_set_mode_root_back_btn(menu, LV_MENU_ROOT_BACK_BTN_ENABLED);
lv_obj_t* cont;
lv_obj_t* label;
/*Create a main page*/
lv_obj_t* main_page = lv_menu_page_create(menu, NULL);
label = lv_label_create(main_page);
lv_label_set_text(label, "Item 1");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
lv_menu_set_page(menu, main_page);
}