1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/widgets/tabview/lv_example_tabview_1.c

43 lines
1.4 KiB
C
Raw Normal View History

2021-04-08 13:07:48 +02:00
#include "../../lv_examples.h"
2021-02-14 14:56:34 +01:00
#if LV_USE_TABVIEW && LV_BUILD_EXAMPLES
2021-02-08 09:53:03 +01:00
void lv_example_tabview_1(void)
{
/*Create a Tab view object*/
lv_obj_t *tabview;
2021-02-10 22:59:53 +01:00
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 50);
2021-02-08 09:53:03 +01:00
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2");
lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");
/*Add content to the tabs*/
lv_obj_t * label = lv_label_create(tab1);
2021-02-08 09:53:03 +01:00
lv_label_set_text(label, "This the first tab\n\n"
"If the content\n"
"of a tab\n"
"becomes too\n"
"longer\n"
"than the\n"
"container\n"
"then it\n"
"automatically\n"
"becomes\n"
"scrollable.\n"
"\n"
"\n"
"\n"
"Can you see it?");
label = lv_label_create(tab2);
2021-02-08 09:53:03 +01:00
lv_label_set_text(label, "Second tab");
label = lv_label_create(tab3);
2021-02-08 09:53:03 +01:00
lv_label_set_text(label, "Third tab");
2021-05-20 12:08:24 +02:00
lv_obj_scroll_to_view_recursive(label, LV_ANIM_ON);
2021-02-08 09:53:03 +01:00
}
#endif