I have some questions about tileview widget

After testing, I found out: The coordinates of tileview widget are based on LV_HOR_RES_MAX and LV_VER_RES_MAX. right?

when i use follow code ,The logic of tileview widget is error.

static void widget_tileview2(void)
{
    const uint16_t hor_size = 150;//300 ok,but 200,150 issure
    const uint16_t ver_size = 300;

    static lv_point_t valid_pos[] = { {0,0}, {1, 0}, {2,0}, {3,0}, {0,1}, {0,2}, {0,3}, {0,4}};
    static lv_style_t style;

    lv_style_init(&style);
    lv_style_set_pad_top(&style, LV_STATE_DEFAULT, 0);
    lv_style_set_pad_left(&style, LV_STATE_DEFAULT, 0);
    lv_style_set_pad_right(&style, LV_STATE_DEFAULT, 0);
    lv_style_set_pad_bottom(&style, LV_STATE_DEFAULT, 0);


    lv_obj_t* bg = lv_obj_create(lv_scr_act(), NULL);
    lv_obj_set_size(bg, hor_size, ver_size);
    lv_obj_align(bg, NULL, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_style(bg, LV_OBJ_PART_MAIN, &style);

    lv_obj_t* tileview;
    tileview = lv_tileview_create(bg, NULL);
    lv_tileview_set_valid_positions(tileview, valid_pos, 8);
    lv_tileview_set_edge_flash(tileview, true);

    for (int i = 0; i < 4; i++) {
        lv_obj_t* par = lv_obj_create(tileview, NULL);
        lv_obj_set_size(par, hor_size, ver_size);
        lv_obj_set_pos(par, i * hor_size, 0);
        lv_tileview_add_element(tileview, par);

        lv_obj_t* label = lv_label_create(par, NULL);
        lv_label_set_text_fmt(label, "this is (%d,%d)",i,0);
        lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
    }
    for (int i = 1; i < 5; i++) {
        lv_obj_t* par = lv_obj_create(tileview, NULL);
        lv_obj_set_size(par, hor_size, ver_size);
        lv_obj_set_pos(par, 0, i * ver_size);
        lv_tileview_add_element(tileview, par);

        lv_obj_t* label = lv_label_create(par, NULL);
        lv_label_set_text_fmt(label, "this is (%d,%d)", 0, i);
        lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
    }
}


but when hor_size = LV_HOR_RES_MAX and ver_size = LV_VER_RES_MAX, is ok.

Shouldn’t it depend on his father? is bug?

Hi,

There was bug when the tileview is not screen sized. I’ve fixed it in the master.

1 Like