How to switch to next tab without scroll

I’m not sure you can prevent it behaving like that when scrolling.

I know you can do that when using the buttons at the top/left but you seem to have made your content to be 100% height/width and this is probably making the buttons not show.

To stop the scroll animation when using the buttons at the top you can do something like this:

  tv = lv_tabview_create(scr, LV_DIR_TOP, tvHeight);
  lv_obj_add_event_cb(lv_tabview_get_content(tv), scroll_begin_event, LV_EVENT_SCROLL_BEGIN, NULL);  

static void scroll_begin_event(lv_event_t * e)
{
    /*Disable the scroll animations. Triggered when a tab button is clicked */
    if(lv_event_get_code(e) == LV_EVENT_SCROLL_BEGIN) {
        lv_anim_t * a = (lv_anim_t *)lv_event_get_param(e);
        //lv_anim_t * a = lv_event_get_param(e);
        if(a)  a->time = 0;
    }
}
1 Like