您当前的位置: 首页 > 

仙剑情缘

暂无认证

  • 0浏览

    0关注

    333博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

LVGL V8之border styles

仙剑情缘 发布时间:2021-08-15 19:12:18 ,浏览量:0

创建style
  • 初时化style
    static lv_style_t style;
    lv_style_init(&style);
  • 设置倒角为10
 lv_style_set_radius(&style, 10);
  • 设置背景透明度为不透明
  lv_style_set_bg_opa(&style, LV_OPA_COVER);
  • 设置背景色为淡灰色
lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));
  • 设置边框border颜色为蓝色
 lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE));
  • 设置边框宽度为25
lv_style_set_border_width(&style, 25);
  • 设置边框颜色透明度为50%
lv_style_set_border_opa(&style, LV_OPA_50);
  • 设置边框为底部边框和右边边框显示
lv_style_set_border_side(&style, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT);
  • 创建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_3(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    /*Set a background color and a radius*/
    lv_style_set_radius(&style, 10);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));
    /*Add border to the bottom+right*/
    lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_border_width(&style, 25);
    lv_style_set_border_opa(&style, LV_OPA_50);
    lv_style_set_border_side(&style, LV_BORDER_SIDE_BOTTOM | LV_BORDER_SIDE_RIGHT);
    /*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_3运行效果

在这里插入图片描述

  • 分解注释图 在这里插入图片描述
关注
打赏
1658017818
查看更多评论
立即登录/注册

微信扫码登录

0.0638s