您当前的位置: 首页 > 

LVGL V8之Outline styles

发布时间:2021-08-15 20:06:01 ,浏览量:5

创建style
  • 初时化style
static lv_style_t style; lv_style_init(&style); 
  • 设置倒角为5
lv_style_set_radius(&style, 5); 
  • 设置背景透明度为不透明
lv_style_set_bg_opa(&style, LV_OPA_COVER); 
  • 设置背景色为淡灰色
lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1)); 
  • 设置边框线宽为2
lv_style_set_outline_width(&style, 2); 
  • 设置边框线颜色为蓝色
lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE)); 
  • 设置边框padding为18
lv_style_set_outline_pad(&style, 18); 
  • 创建obj对象,添加style,居中显示
lv_obj_t* obj = lv_obj_create(lv_scr_act()); lv_obj_add_style(obj, &style, 0); lv_obj_center(obj); 
完整代码,仅供参考
static void lv_example_style_4(void) { static lv_style_t style; lv_style_init(&style); /*Set a background color and a radius*/ lv_style_set_radius(&style, 5); lv_style_set_bg_opa(&style, LV_OPA_COVER); lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1)); lv_style_set_outline_width(&style, 2); lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE)); lv_style_set_outline_pad(&style, 18); /*Create an object with the new style*/ lv_obj_t* obj = lv_obj_create(lv_scr_act()); lv_obj_add_style(obj, &style, 0); lv_obj_center(obj); } 
调用lv_example_style_4运行效果

在这里插入图片描述

  • 调用分解图 在这里插入图片描述
关注
打赏
1688896170
查看更多评论

暂无认证

  • 5浏览

    0关注

    115984博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0904s