创建自定义circular scrolling文本滚动效果
static void lv_example_label_5(void) { static lv_anim_t animation_template; /动画变量定义 static lv_style_t label_style; lv_anim_init(&animation_template); lv_anim_set_delay(&animation_template, 1000); //设置等待1秒开始动画 lv_anim_set_repeat_delay(&animation_template, 3000); // 动画回到初时位置后延时3秒重复滚动 /*Initialize the label style with the animation template*/ lv_style_init(&label_style); lv_style_set_anim(&label_style, &animation_template); // sytle关联动画变量 lv_obj_t* label1 = lv_label_create(lv_scr_act()); //创建label lv_label_set_long_mode(label1, LV_LABEL_LONG_SCROLL_CIRCULAR); //Circular scroll模式 lv_obj_set_width(label1, 150); // 设置宽度 lv_label_set_text(label1, "It is a circularly scrolling text. ");//设置文本内容 lv_obj_align(label1, LV_ALIGN_CENTER, 0, 40);//LV_ALIGN_CENTER方式对齐 lv_obj_add_style(label1, &label_style, LV_STATE_DEFAULT); //label添加style }运行效果