How to close the tabview scroll funtion and scroll anim?

just slide then refresh to next tab, no scroll funtion.

Does it really have to be a tabview (i.e. do you need the headers with the tab names?) or is it enough to have only the containers next to each other?

  • It could be a neighboring container. Now I use the scene to make a menu. But there is a lag when turning the page because of the sliding effect.

In this case you can easily create the containers like here: Examples — LVGL documentation

And use the gestures. By getting the current scroll x coordinate (with lv_obj_get_scoll_x) you can figure out which one is the currently visible container and focus on the next one with lv_obj_scroll_into_view() function.

you mean: no use “tabview”, create a container and put all the ICONS on it. Then set the scroll effect to turn off or use ''lv_obj_scroll_into_view()"function to refresh directly.

Maybe you misunderstood my scene. use "lv_obj_scroll_into_view()"funtion also have the scroll anim. i just need to close the anim.

Now i change the “cont_scroll_end_event_cb” in “lv_tabview.c”, set “lv_tabview_set_act(tv, t, LV_ANIM_OFF);”, but it have a little effect. It can refresh directly when my finger is off the screen.

I’m hope that when my finger is move in screen, the icon don’t move. But the page turning when my finger is off the screen.

Here is an example (It’s a little bit different to what I have suggested):

static void gesture_event_cb(lv_event_t * e)
{
    lv_obj_t * obj = lv_event_get_target(e);
    lv_dir_t d = lv_indev_get_gesture_dir(lv_indev_get_act());
    int32_t *p = lv_event_get_user_data(e);
    if(d == LV_DIR_LEFT) (*p)++;
    if(d == LV_DIR_RIGHT) (*p)--;

    *p = LV_CLAMP(0, *p, lv_obj_get_child_cnt(obj) - 1);
    lv_obj_scroll_to(obj, lv_obj_get_x(lv_obj_get_child(obj, *p)), 0, LV_ANIM_OFF);
}

...

  lv_obj_t * parent = lv_obj_create(lv_scr_act());
  lv_obj_set_size(parent, 400, 300);
  lv_obj_clear_flag(parent, LV_OBJ_FLAG_GESTURE_BUBBLE);
  lv_obj_clear_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
  lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_ROW);

  static int32_t page = 0;
  lv_obj_add_event_cb(parent, gesture_event_cb, LV_EVENT_GESTURE, &page);

  uint32_t i;
  for(i = 0; i < 5; i++) {
      lv_obj_t * cont = lv_obj_create(parent);
      lv_obj_set_size(cont, lv_pct(100), lv_pct(100));
      lv_obj_t * label = lv_label_create(cont);
      lv_label_set_text_fmt(label, "%d", i);
  }

The transplant test results were goodThanks a lot. :handshake:

1 Like

A problem has been found with this modification:when my finger slide , it will trigger clicking on the icon.
(such as i am going to turn the page now, there are ICONS where my finger is pressing down,then my finger slide and page is turning,but at the same time the imgbtn will be pressed.)
I try to change the imgbtn for "lv_obj_add_event_cb(imgbtn2, event_handler_Click, LV_EVENT_RELEASED, MODULE_WORD_DICTATION);"or other value, but that’s not the point.

I can not speak English very well. :sweat_smile:
From what I understand, it seems that press lock should be used for the obj to which the scroll event is applied. Is that correct…?

lv_obj_add_flag(obj , LV_OBJ_FLAG_PRESS_LOCK);

Maybe no, now i’m add imgbtn on the tabview widgets.
Then close scroll anim like “lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);”
in funtion “static void lv_tabview_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)”.

My imgbtn event is “lv_obj_add_event_cb(imgbtn2, event_handler_Click, LV_EVENT_CLICKED, MODULE_WORD_DICTATION);”

The “LV_EVENT_CLICKED” mean “/**< Called on release if not scrolled (regardless to long press)*/”

It have conflict.