Tab View (lv_tabview)
The Tab View Widget can be used to organize content in tabs.
Overview
The Tab View Widget can be used to organize content in tabs. The Tab View is built from other Widgets:
- Main container: base widget
- Tab buttons: an base widget with Button (lv_button)
- Container for the tabs: base widget
- Content of the tabs: base widget
The tab buttons can be positioned on the top, bottom, left, and right side of the Tab View.
A new tab can be selected either by clicking on a tab button or by sliding horizontally on the content.
Parts and Styles
There are no special parts on the Tab View but the base widget and Button (lv_button) Widgets are used to create the Tab View.
Usage
Creating a Tab View
lv_tabview_create(parent) creates a new empty Tab View.
Adding tabs
New tabs can be added with lv_tabview_add_tab(tabview, "Tab name").
This will return a pointer to a base widget where
the tab's content can be created.
Renaming tabs
A tab can be renamed with
lv_tabview_set_tab_text(tabview, tab_id, "New Name").
Navigating to a new tab
To select a new tab you can:
- Click on its tab button
- Slide horizontally
- Use
lv_tabview_set_active(tabview, tab_id, LV_ANIM_ON / OFF)function
Setting tab bar position
Using the lv_tabview_set_tab_bar_position(tabview, LV_DIR_LEFT/RIGHT/TOP/BOTTOM)
the tab bar can be moved to any side.
Setting tab bar size
The size of the tab bar can be adjusted by lv_tabview_set_tab_bar_size(tabview, size).
When tabs are on the top or bottom, this means the height of the tab bar, and when
they are on the sides, it means the width.
Accessing the parts
lv_tabview_get_content(tabview)returns a pointer to the container for tabs content (a base widget)lv_tabview_get_tab_bar(tabview)returns a pointer to the container for tab buttons (a base widget)
Events
LV_EVENT_VALUE_CHANGEDSent when a new tab is selected by sliding or clicking the tab button.lv_tabview_get_tab_active(tabview)returns the zero based index of the current tab.
Keys
Keys have effect only on the tab buttons. Programmatically add these buttons to a group if required.
Further Reading
Learn more about Keys.
Examples
Simple Tabview
Tabs on the left, styling and no scrolling
API
How is this guide?
Last updated on