How to set the view of a page to the bottom?

Description

When a page has height is 240 px,
and it has 5 child-containers (eash height is 70px)
that total of these containers is more than the page’s height
( 5x70 = 350px …more than the page’s height 240px).

I would like to move the view of the page to the lower container.
How to set the view of this page to the bottom?

Thank you.

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

  • ESP32

What do you want to achieve?

As the description.

What have you tried so far?

Code to reproduce

  lv_obj_t* page = lv_page_create(lv_scr_act(), NULL);
  lv_obj_set_size(page,240,240);
  lv_page_set_scrl_layout(page, LV_LAYOUT_COL_M);
  lv_page_set_sb_mode(page, LV_SB_MODE_AUTO);

  static lv_style_t page_style; 
  lv_style_copy(&page_style, &lv_style_plain);
  lv_page_set_style(page, LV_PAGE_STYLE_SCRL, &page_style);
  page_style.body.padding.inner = 0;
  page_style.body.padding.top = 0;
  page_style.body.padding.bottom = 0;
  page_style.body.padding.left = 0;
  page_style.body.padding.right = 0;
  

  for(int i=0; i < 5; i++ ) {
    lv_obj_t* cont = lv_cont_create(page, NULL);
    lv_obj_set_size(cont,240,70);
    lv_obj_set_parent_event(cont, true);
    lv_obj_set_drag_parent(cont, true);
  }

Screenshot and/or video

hi have you try to set :

 for(int i=0; i < 5; i++ ) {
    lv_obj_t* cont = lv_cont_create(page, NULL);
    lv_obj_set_size(cont,240,70);
   lv_obj_set_drag(cont, true);  //<--- here 
    lv_obj_set_parent_event(cont, true);
   lv_obj_set_drag_parent(cont, true); // last line of your code
}

The page can drag automatally by default,
however I want to set the view of page at the first time to the bottom of the page
instead of the top of the page.

Manual navigation

You can move the scrollable object manually using lv_page_scroll_hor(page, dist) and lv_page_scroll_ver(page, dist)

2 Likes

Thank you very much. @Ulric_Denis

@Ulric_Denis Usually, it’s better to link to the relevant section of the documentation instead of copying it because that way people who read the post later can find the most up-to-date information.

1 Like

Just a minor extra info to @Ulric_Denis’s answer. You can set a very large dist because the page will limit it. E.g. lv_page_scroll_ver(page, 10000)

1 Like

Thank you for the trick.