How to set a new event-callback for tabview

At the current version lvgl (6.0.2),
there is no API for a maker to change the tab’s width or the tab’s height.

But you can add additional API by yourself at lv_tabview.c
for the TabView with right/left-position tabs
you can add your additional API code between these lines

I set the padding left/right, but it don’t work,

Link to v6.1: https://github.com/littlevgl/lvgl/tree/dev-6.1
You can download or clone it from here.

I’ve just noticed that I still still see 1 px error. It should be rounding. It’s not sure that it will be visible on your screen too.

Are you sure you set style_tv_btn_rel?

yes, I even set the style_tv_btn_tgl_rel.body.padding.left/right

thanks, for the indicator postion align, is there something suitable solution?

I am waiting for the next official version from @kisvegabor .
But if you want to adjust by yourself

At line 1061, it is about align of the indic for the left-position tabs

lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_RIGHT, 0, 0);

I adjust the 5 parameter, but it seems don’t work.

Adjust at line 1107 too.

hi:
1、maybe I think it should adjust at line 1006, but I don’t know how to adjust it. It seems the last button’s indicator height will be a little shorter.

1006     lv_obj_set_height(ext->indic, indic_size);

2、I have one more questions about tabview details. First, can I set the tabview’s button like image button to change the button’s background? I prefer to use my own button background picture. Second, I notice that it has a sliding effect between two tabs swtich action, how to disabled the sliding effect? I try to use

lv_tabview_set_sliding(lv_obj_t* tabview, bool en)

but it doesn’t work.

1 Like
  1. if you want to adjust the last height of the indic, let’s try like
    @kisvegabor advice

kisvegabor

To set width you should use:

style_tv_btn_rel.body.padding.left = 20;
style_tv_btn_rel.body.padding.right = 20;

but try for the left-position tab let’s try by adjusting

style_btn_bg.body.padding.top = 0; // maybe
style_btn_bg.body.padding.bottom=0; //maybe

  1. any tab of a tabview is a buttonmatrix,
    a buttonmatrix is not support image, support only string (char array);

When an API doesn’t work the way you expect it’s always a good idea to have a look at the relevant part of the documentation.

Enable horizontal sliding with touch pad

That means that lv_tabview_set_sliding enables the ability to slide, not the animation.

I think what you are looking for is disabling animation for the tabview in lv_conf.h.