lvgl v8 obj支持滚动但不显示滚动条以及禁用滚动条
·
从lvgl v8版本开始,lvgl的obj默认开启了滚动条。
对于滚动条一般有三种需求:
- 保留滚动条,那就不用改变,默认是开启的滚动条,超出obj的部分可以滚动过去显示
- 禁用滚动条,obj不需要滚动
- 保留滚动条,不显示滚动条
第2种obj实现:
lv_obj_t * obj = lv_obj_create(desktop_app.bg_win);
lv_obj_set_pos(obj, 20, 380);
lv_obj_set_size(obj, 400, 100);
// lv_obj_set_style_bg_color(obj, lv_color_hex(0x1F1F1F), 0);
lv_obj_t *label = lv_label_create(obj);
lv_label_set_text(label, "I am fine....hsahhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaahnnnngj");
// lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_scroll_dir(obj, LV_DIR_HOR);
lv_obj_set_style_bg_color(obj, lv_color_hex(0x1F1F1F), 0);
lv_obj_set_style_text_color(obj, lv_color_hex(0xFFFFFF), 0);
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
禁用滚动条lv_obj_set_scroll_dir(obj, LV_DIR_VER);
设置滚动方向,LV_DIR_HOR水平滚动
,LV_DIR_VER垂直滚动
第3种obj实现:
lv_obj_t * obj = lv_obj_create(desktop_app.bg_win);
lv_obj_set_pos(obj, 20, 380);
lv_obj_set_size(obj, 400, 100);
// lv_obj_set_style_bg_color(obj, lv_color_hex(0x1F1F1F), 0);
lv_obj_t *label = lv_label_create(obj);
lv_label_set_text(label, "I am fine....hsahhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaahnnnngj");
lv_obj_set_scroll_dir(obj, LV_DIR_HOR);
lv_obj_set_style_bg_opa(obj, LV_OPA_0, LV_PART_SCROLLBAR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(obj, LV_OPA_0, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
lv_obj_set_style_bg_color(obj, lv_color_hex(0x1F1F1F), 0);
lv_obj_set_style_text_color(obj, lv_color_hex(0xFFFFFF), 0);
lv_obj_set_style_bg_opa(obj, LV_OPA_0, LV_PART_SCROLLBAR | LV_STATE_DEFAULT)
,设置样式将obj滚动条的颜色默认为透明,lv_obj_set_style_bg_opa(obj, LV_OPA_0, LV_PART_SCROLLBAR | LV_STATE_SCROLLED)
,设置样式将obj滚动条滚动时的颜色也设置为透明
更多推荐
已为社区贡献4条内容
所有评论(0)