Get current active tile in tileview

I set my active tile with…

lv_tileview_set_tile_act(tileview, 0 , 0, LV_ANIM_OFF);

how can i later check to see which tile is active eg…

if (lv_tileview_get_tile_act(tileview)) == 1)
{
foo();
};

There’s no API for it right now, but you can safely use this:

((lv_tileview_ext_t *)lv_obj_get_ext_attr(tileview))->act_id.x (or y, depending on which you want).

If anyone wishes to send a pull request adding lv_tileview_get_act_x/y, they’re welcome to do so.

3 Likes

My solution for lvgl v8 looks like this:

lv_obj_t *tile_obj = lv_tileview_get_tile_act(tv);
lv_coord_t tile_x = lv_obj_get_x(tile_obj) / 476; //476 is the width of tv

remember to use

    lv_obj_set_tile_id(tv, 0, 0, LV_ANIM_OFF);

befor trying to use lv_tileview_get_tile_act otherwise i get error

1 Like