LVGL7.0页面创建

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");
}

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值