LVGL lv_label标签控件(5)

lv_label

相关API在lv_label.h中

文本模式

enum {
	/*实时自动扩展标签对象大小来包裹文本内容*/
    LV_LABEL_LONG_EXPAND,    /**< Expand the object size to the text size*/
    //标签对象宽度不变,当文本内容超过标签对象宽度,自动换行文本内容
    LV_LABEL_LONG_BREAK,     /**< Keep the object width, break the too long lines and expand the object
                                height*/
    //标签对象大小不变,当文本内容太长时,显示...省略号
    LV_LABEL_LONG_DOT,       /**< Keep the size and write dots at the end if the text is too long*/
    //标签对象大小不变,当文本内容太长时,会自动循环向前向后滚动文本
    LV_LABEL_LONG_SROLL,      /**< Keep the size and roll the text back and forth*/
    //标签对象大小不变,当文本内容太长时,会自动循环环形滚动文本
    LV_LABEL_LONG_SROLL_CIRC, /**< Keep the size and roll the text circularly*/
    //保持对象大小不变,超过的文本内容将会被剪切掉
    LV_LABEL_LONG_CROP,      /**< Keep the size and crop the text out of it*/
};

对齐方式

/** Label align policy*/
enum {
    LV_LABEL_ALIGN_LEFT, /**< Align text to left */
    LV_LABEL_ALIGN_CENTER, /**< Align text to center */
    LV_LABEL_ALIGN_RIGHT, /**< Align text to right */
    LV_LABEL_ALIGN_AUTO, /**< Use LEFT or RIGHT depending on the direction of the text (LTR/RTL)*/
};

标签样式

/** Label styles*/
enum {
    LV_LABEL_PART_MAIN,
};

例子

void lv_ex_label_1(void)
{
	//创建标签对象
    lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
	//设置长文本模式
    lv_label_set_long_mode(label1, LV_LABEL_LONG_BREAK);     /*Break the long lines*/
	//使能文本重绘色功能
    lv_label_set_recolor(label1, true);                      /*Enable re-coloring by commands in the text*/
	//设置文本对齐模式
    lv_label_set_align(label1, LV_LABEL_ALIGN_CENTER);       /*Center aligned lines*/
	//设置文本内容
    lv_label_set_text(label1, "#ff0000 Re-color# #00ff00 words# #0000ff of a# label "
								"and  wrap long text automatically.");
	//设置宽度
    lv_obj_set_width(label1, 150);
	//设置对齐模式
    lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, -30);

    lv_obj_t * label2 = lv_label_create(lv_scr_act(), NULL);
    lv_label_set_long_mode(label2, LV_LABEL_LONG_SROLL_CIRC);     /*Circular scroll*/
    lv_obj_set_width(label2, 150);
    lv_label_set_text(label2, "It is a circularly scrolling text. ");
    lv_obj_align(label2, NULL, LV_ALIGN_CENTER, 0, 30);
}

模拟效果
在这里插入图片描述
of后面的a也应该是蓝色,单片机拍照实际效果如下
在这里插入图片描述

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值