hello world 代码演示
LVGL 应用开发是面向对象的开发方式
|
lv_obj_t *main_label = lv_label_create(img_bg); |
是什么,叫什么,来自哪里 |
|
lv_obj_set_height(main_label, 50); lv_obj_set_width(main_label, 100); |
高矮胖瘦 |
|
lv_obj_set_style_text_color(main_label, lv_color_hex(0x000000), 0); lv_obj_set_style_bg_color(main_label, lv_color_hex(0x00ffff), 0); |
肤色、发色、衣服颜色 |
|
lv_obj_set_pos(main_label, 50, 50); |
站在哪里 |
|
lv_obj_add_event_cb(main_label, main_label_event, LV_EVENT_ALL, NULL); |
准备干什么 |
hello world
代码演示:
static lv_obj_t * main_label = NULL;
static void main_label_event (lv_event_t *e) {
lv_label_set_text(main_label, "helloworld");
}
void helloworld_ui_init()
{
lv_obj_t * img_bg;
img_bg = lv_image_create(lv_scr_act());
main_label = lv_label_create(img_bg);
lv_label_set_text(main_label, "Label");
lv_label_set_long_mode(main_label, LV_LABEL_LONG_WRAP);
lv_obj_set_pos(main_label, 61, 48);
lv_obj_set_size(main_label, 100, 32);
lv_obj_add_flag(main_label, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_style_bg_color(main_label, lv_color_hex(0x00ffff), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_color(main_label, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_add_event_cb(main_label, main_label_event, LV_EVENT_ALL, NULL);
}
LVGL 更多控件使用方法
官方网站:LVGL: Light and Versatile Graphics Library — LVGL documentation
网上视频教程:可以在 B 站搜索 LVGL 相关视频教程。
