I want to set the size of the scrollbar ,how to do?
#include “…/…/lv_examples.h”
#if LV_USE_TILEVIEW && LV_BUILD_EXAMPLES
/**
-
Create a 2x2 tile view and allow scrolling only in an “L” shape.
-
Demonstrate scroll chaining with a long list that
-
scrolls the tile view when it can’t be scrolled further.
/
static void event_cb(lv_event_t e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t* label = lv_event_get_user_data(e);switch (code) {
case LV_EVENT_PRESSED:
lv_label_set_text(label, “The last button event:\nLV_EVENT_PRESSED”);
break;
case LV_EVENT_CLICKED:
lv_label_set_text(label, “The last button event:\nLV_EVENT_CLICKED”);
break;
case LV_EVENT_LONG_PRESSED:
lv_label_set_text(label, “The last button event:\nLV_EVENT_LONG_PRESSED”);
break;
case LV_EVENT_LONG_PRESSED_REPEAT:
lv_label_set_text(label, “The last button event:\nLV_EVENT_LONG_PRESSED_REPEAT”);
break;
case LV_EVENT_SCROLL:
lv_label_set_text(label, “The last button event:\nLV_EVENT_SCROLL”);
break;
case LV_EVENT_GESTURE:
lv_label_set_text(label, “The last button event:\nLV_EVENT_GESTURE”);
break;case LV_EVENT_DRAW_PART_END:
lv_label_set_text(label, “The last button event:\nLV_EVENT_DRAW_PART_END”);
break;default:
break;
}
}
void lv_example_tileview_1(void)
{
lv_obj_t tv = lv_tileview_create(lv_scr_act());
lv_point_t scroll;
lv_obj_set_size(tv,278,166);//lv_obj_remove_style(tv, NULL, LV_PART_SCROLLBAR | LV_STATE_ANY);
lv_obj_align(tv, LV_ALIGN_CENTER, 0, 0);lv_obj_set_scrollbar_mode(tv,LV_SCROLLBAR_MODE_ON);
//lv_obj_set_style_width(tv, 16 , LV_PART_SCROLLBAR );
//lv_obj_set_style_height(tv, 30, LV_PART_SCROLLBAR);
lv_obj_set_scroll_snap_x(tv, LV_SCROLL_SNAP_CENTER);static lv_style_t test_style;
lv_style_init(&test_style);
lv_style_set_bg_color(&test_style, lv_color_hex(0xff0000));
lv_style_set_bg_opa(&test_style, 255);
lv_style_set_width(&test_style,16);
lv_style_set_height(&test_style, 90);
lv_style_set_border_color(&test_style, lv_palette_darken(LV_PALETTE_BLUE, 3));
lv_style_set_border_width(&test_style, 2);lv_obj_add_style(tv, &test_style, LV_PART_SCROLLBAR);
//lv_obj_set_style_bg_color(tv,lv_color_hex(0xff0000), LV_PART_SCROLLBAR|LV_STATE_SCROLLED);
/Tile1: just a label/
lv_obj_t* tile;
for (int i = 0; i < 10; i++)
{
tile= lv_tileview_add_tile(tv, 0, i, LV_DIR_TOP | LV_DIR_BOTTOM);
lv_obj_t* label = lv_label_create(tile);
lv_label_set_text(label, “222222222”);
lv_obj_align(label, LV_ALIGN_CENTER,0,0);
}lv_obj_t* info_label = lv_label_create(lv_scr_act());
lv_label_set_text(info_label, “The last button event:\nNone”);
lv_obj_add_event_cb(tv, event_cb, LV_EVENT_ALL, info_label);
}
#endif