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也应该是蓝色,单片机拍照实际效果如下