1、Page
看源码是基于cont创建
void Home_Page_Create(void)
{
static lv_style_t page_style;
lv_style_init(&page_style);
/*Set a background color and a radius*/
lv_style_set_radius(&page_style, LV_STATE_DEFAULT, 0);//设置页面圆角度数
lv_style_set_bg_opa(&page_style, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&page_style, LV_STATE_DEFAULT, LV_COLOR_WHITE);//设置页面底色
lv_style_set_border_color(&page_style, LV_STATE_FOCUSED, LV_COLOR_WHITE);//页面聚焦边线色
lv_style_set_border_color(&page_style, LV_STATE_DEFAULT, LV_COLOR_WHITE);//页面默认边线色
/*Create a page*/
lv_obj_t* page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_size(page, 800, 480);
lv_obj_align(page, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
lv_obj_add_style(page, LV_GAUGE_PART_MAIN, &page_style);
/*Create a label on the page*/
lv_obj_t* label = lv_label_create(page, NULL);
lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK); /*Automatically break long lines*/
lv_obj_set_width(label, lv_page_get_width_fit(page)); /*Set the label width to max value to not show hor. scroll bars*/
lv_label_set_text(label, "Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n"
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"
"Ut enim ad minim veniam, quis nostrud exercitation ullamco\n"
"laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure\n"
"dolor in reprehenderit in voluptate velit esse cillum dolore\n"
"eu fugiat nulla pariatur.\n"
"Excepteur sint occaecat cupidatat non proident, sunt in culpa\n"
"qui officia deserunt mollit anim id est laborum.");
// lv_page_clean(page);//清空页面
}
2、tabview
看源码是基于page创建
void Home_Page_Create(void)
{
/*Create a Tab view object*/
lv_obj_t* tabview;
tabview = lv_tabview_create(lv_scr_act(), NULL);//创建一个tabview
lv_tabview_set_btns_pos(tabview, LV_TABVIEW_TAB_POS_NONE);//不显示btns
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
lv_obj_t* tab1 = lv_tabview_add_tab(tabview, "Tab 1");//创建第一页
lv_obj_t* tab2 = lv_tabview_add_tab(tabview, "Tab 2");//创建第二页
lv_obj_t* tab3 = lv_tabview_add_tab(tabview, "Tab 3");//创建第三页
/*Add content to the tabs*/
lv_obj_t* label = lv_label_create(tab1, NULL);//在第一页创建文本
lv_label_set_text(label, "This the first tab\n\n"
"If the content\n"
"of a tab\n"
"become too long\n"
"the it \n"
"automatically\n"
"become\n"
"scrollable.");
label = lv_label_create(tab2, NULL);//在第二页创建文本
lv_label_set_text(label, "Second tab");
lv_tabview_clean_tab(tab2);//清空当前页面
label = lv_label_create(tab3, NULL);//在第三页创建文本
lv_label_set_text(label, "Third tab");
}