avatar

松果工作室

欢迎光临

  • 首页
  • freeRTOS
  • LVGL
  • ESP
  • 开发手册
  • 快速笔记
  • 个人收藏
  • 时事记录
  • 考察日志
  • 工具
Home LVGL(三) 对象中创建对象
文章

LVGL(三) 对象中创建对象

Posted 2025-06-14 Updated 2025-06- 14
By YCP
3~4 min read

万物源于对象

lv_obj_t *lv_example_time_page(lv_obj_t *scr) {
    // 创建时间显示容器的对象
    lv_obj_t *time_container = lv_obj_create(scr);
    // 设置容器样式
    static lv_style_t container_style;
    lv_style_init(&container_style);
    lv_style_set_width(&container_style,250);
    lv_style_set_height(&container_style,90);
    lv_style_set_align(&container_style,LV_ALIGN_CENTER);
    lv_style_set_border_width(&container_style, 0);
    lv_style_set_bg_opa(&container_style, LV_OPA_TRANSP);
    lv_obj_add_style(time_container, &container_style, LV_PART_MAIN);

    // 在容器中创建对象,该对象为文本
    time_label = lv_label_create(time_container);
    lv_label_set_text(time_label, "00:00:00");
    // 设置文本对象样式
    static lv_style_t time_style;
    lv_style_init(&time_style);
    lv_style_set_text_font(&time_style, &lv_font_montserrat_48);
    lv_style_set_align(&container_style,LV_ALIGN_CENTER);
    lv_obj_add_style(time_label, &time_style, LV_PART_MAIN);
}
LVGL
License:  CC BY 4.0
Share

Further Reading

OLDER

LVGL(二) 定时回调

NEWER

LVGL(四) 动画

Recently Updated

  • ESP32(十) BLE OTA
  • ESP32(九) BLE GATTS
  • LVGL(四) 动画
  • LVGL(三) 对象中创建对象
  • LVGL(二) 定时回调

Trending Tags

LVGL WCH Linux Elec freeRTOS STM ESP Flutter Others SwiftUI

Contents

©2025 松果工作室. Some rights reserved.

Using the Halo theme Chirpy