How to fix the position of tabview's children

Important: posts that do not use this template will be ignored or closed.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the relevant part of the documentation. We will not respond in detail to posts where you haven’t read the relevant documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

When I Slide a little on the page of tabview it can’t return to the original position.I try many ways can,t soulve this problem

What MCU/Processor/Board and compiler are you using?

visual studio

What do you want to achieve?

Deal some problems of plug-ins in lvgl

What have you tried so far?

set the position of tabview’s children as the absolute position

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/
```static lv_style_t tabviewStyle;
    tabview = lv_tabview_create(lv_scr_act(), NULL);
    lv_obj_set_size(tabview, LV_HOR_RES, LV_VER_RES);
    lv_tabview_set_btns_pos(tabview, LV_TABVIEW_TAB_POS_NONE);
    lv_obj_add_style(tabview, LV_OBJ_PART_MAIN, CommonGetDefaultBgStyle());

    lv_obj_set_pos(tabview, 0, 0);
    tab0 = lv_tabview_add_tab(tabview, "Tab0");
    tab1 = lv_tabview_add_tab(tabview, "Tab1");
    lv_page_set_scrlbar_mode(tab0, LV_SCRLBAR_MODE_OFF);
    lv_page_set_scrlbar_mode(tab1, LV_SCRLBAR_MODE_OFF);
    lv_obj_set_event_cb(tabview, tabview_event_handler);
    lv_tabview_set_tab_act(tabview, 1, LV_ANIM_OFF);
   
   static lv_style_t rollerbgstyle, rollerselstyle;
   lv_style_reset(&rollerselstyle);
    lv_style_init(&rollerselstyle);
    lv_style_set_bg_color(&rollerselstyle, LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_style_set_radius(&rollerselstyle, LV_STATE_DEFAULT, 1);
    lv_style_set_bg_opa(&rollerselstyle, LV_STATE_DEFAULT, LV_OPA_0);
    lv_style_set_text_color(&rollerselstyle, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x00, 0xd8, 0xff));
    /*roller backgroud style set*/
	lv_style_reset(&rollerbgstyle);
    lv_style_init(&rollerbgstyle);
    lv_style_set_bg_color(&rollerbgstyle, LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_style_set_bg_opa(&rollerbgstyle, LV_STATE_DEFAULT, LV_OPA_100);
    lv_style_set_radius(&rollerbgstyle, LV_STATE_DEFAULT, 12);
    lv_style_set_text_font(&rollerbgstyle, LV_STATE_DEFAULT, &Alibaba_PuHuiTi_M_Alarm30px);
    lv_style_set_text_opa(&rollerbgstyle, LV_STATE_DEFAULT, LV_OPA_100);
    lv_style_set_text_line_space(&rollerbgstyle, LV_STATE_DEFAULT, 42);
    lv_style_set_text_color(&rollerbgstyle, LV_STATE_DEFAULT, LV_COLOR_GRAY);

    addtimeroller[HOUR] = lv_roller_create(tab1, NULL);
	lv_obj_add_style(edittimeroller[HOUR], LV_ROLLER_PART_BG, &rollerbgstyle);
	lv_obj_add_style(edittimeroller[HOUR], LV_ROLLER_PART_SELECTED, &rollerselstyle);
    lv_roller_set_options(addtimeroller[HOUR], HourBuf, LV_ROLLER_MODE_INIFINITE);
    lv_roller_set_visible_row_count(addtimeroller[HOUR], 3);
    lv_obj_set_event_cb(addtimeroller[HOUR], addalarmselect_event_handler);
    lv_obj_set_pos(addtimeroller[HOUR], 76, 68);
## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.![2|322x394](upload://eubrznTb3v3JYBpQDQBr5z7vMzs.png) ![1|342x408](upload://6U3yd7dyo1JwrarqaiLaYnCeLfR.png)

1 2

I tried to reproduced the issue but some varaibles are not defined in your code snippet.

I’m very sorry omiss some definitions


enum
{
HOUR,
MINUTE,
NOTIME
}
static lv_obj_t *tabview=NULL:
static lv_obj_t *tab1=NULL;
static lv_obj_t *tab0=NULL;
static lv_obj_t *addAlarmRoller[NOTIME]=NULL;
static lv_style_t imgBtnStyle,rollerbgstyle,rollerselstyle;
static const char *hourRollerData = “00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23”;
static const char *minuteRollerData = “00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29”
“\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59”;

lv_obj_t *cfmbtn = lv_imgbtn_create(tab1, NULL);
lv_style_reset(&imgBtnStyle);
lv_style_init(&imgBtnStyle);
lv_style_set_radius(&imgBtnStyle, LV_STATE_DEFAULT, 5);
lv_style_set_image_recolor_opa(&imgBtnStyle, LV_STATE_DEFAULT, LV_OPA_0);
lv_style_set_image_recolor_opa(&imgBtnStyle, LV_STATE_PRESSED, LV_OPA_0);

lv_imgbtn_set_src(cfmbtn, LV_BTN_STATE_RELEASED, &(heartrate_continuous_refresh_icon));
lv_imgbtn_set_src(cfmbtn, LV_BTN_STATE_PRESSED, &(heartrate_continuous_refresh_icon));
lv_obj_add_style(cfmbtn, LV_IMGBTN_PART_MAIN, &imgBtnStyle);
lv_obj_set_event_cb(cfmbtn, event);
lv_obj_align(cfmbtn, NULL, LV_ALIGN_IN_TOP_MID, 0, ypos);
lv_obj_t *label = lv_label_create(cfmbtn, NULL);
lv_obj_set_size(label, 100, 293);
lv_obj_add_style(label, LV_LABEL_PART_MAIN, &btnLabelStyle);
lv_label_set_text(label, text);
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, ypos);

lv_style_reset(&rollerBgStyle);
lv_style_init(&rollerBgStyle);
lv_style_set_bg_color(&rollerBgStyle, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_bg_grad_color(&rollerBgStyle, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_bg_opa(&rollerBgStyle, LV_STATE_DEFAULT, LV_OPA_100);
lv_style_set_radius(&rollerBgStyle, LV_STATE_DEFAULT, 0);
lv_style_set_border_width(&rollerBgStyle, LV_STATE_DEFAULT, 0);
lv_style_set_text_font(&rollerBgStyle, LV_STATE_DEFAULT, &Ali_PuHuiTi_M_25);
lv_style_set_text_opa(&rollerBgStyle, LV_STATE_DEFAULT, LV_OPA_100);
lv_style_set_text_line_space(&rollerBgStyle, LV_STATE_DEFAULT, 42);
lv_style_set_text_color(&rollerBgStyle, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_style_reset(&rollerSelStyle);
lv_style_init(&rollerSelStyle);
lv_style_set_bg_color(&rollerSelStyle, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_bg_grad_color(&rollerSelStyle, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_text_color(&rollerSelStyle, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x00, 0xd8, 0xff));

I’m sorry so long replay, It’s almost time for the project.

Hi,

The icons, fonts and some variables are still missing. :frowning: