当前位置:网站首页>LVGL 8.2 Tabview
LVGL 8.2 Tabview
2022-07-19 19:53:00 【仙剑情缘】
Simple Tabview
static void lv_example_tabview_1(void)
{
/*Create a Tab view object*/
lv_obj_t* tabview;
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 50);
/*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);
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);
lv_label_set_text(label, "Second tab");
label = lv_label_create(tab3);
lv_label_set_text(label, "Third tab");
lv_obj_scroll_to_view_recursive(label, LV_ANIM_ON);
}
- 运行效果
Tabs on the left, styling and no scrolling
static void scroll_begin_event(lv_event_t* e)
{
/*Disable the scroll animations. Triggered when a tab button is clicked */
if (lv_event_get_code(e) == LV_EVENT_SCROLL_BEGIN) {
lv_anim_t* a = lv_event_get_param(e);
if (a) a->time = 0;
}
}
static void lv_example_tabview_2(void)
{
/*Create a Tab view object*/
lv_obj_t* tabview;
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_LEFT, 80);
lv_obj_add_event_cb(lv_tabview_get_content(tabview), scroll_begin_event, LV_EVENT_SCROLL_BEGIN, NULL);
lv_obj_set_style_bg_color(tabview, lv_palette_lighten(LV_PALETTE_RED, 2), 0);
lv_obj_t* tab_btns = lv_tabview_get_tab_btns(tabview);
lv_obj_set_style_bg_color(tab_btns, lv_palette_darken(LV_PALETTE_GREY, 3), 0);
lv_obj_set_style_text_color(tab_btns, lv_palette_lighten(LV_PALETTE_GREY, 5), 0);
lv_obj_set_style_border_side(tab_btns, LV_BORDER_SIDE_RIGHT, LV_PART_ITEMS | LV_STATE_CHECKED);
/*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");
lv_obj_t* tab4 = lv_tabview_add_tab(tabview, "Tab 4");
lv_obj_t* tab5 = lv_tabview_add_tab(tabview, "Tab 5");
lv_obj_set_style_bg_color(tab2, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0);
lv_obj_set_style_bg_opa(tab2, LV_OPA_COVER, 0);
/*Add content to the tabs*/
lv_obj_t* label = lv_label_create(tab1);
lv_label_set_text(label, "First tab");
label = lv_label_create(tab2);
lv_label_set_text(label, "Second tab");
label = lv_label_create(tab3);
lv_label_set_text(label, "Third tab");
label = lv_label_create(tab4);
lv_label_set_text(label, "Forth tab");
label = lv_label_create(tab5);
lv_label_set_text(label, "Fifth tab");
lv_obj_clear_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE);
}
- 运行效果
边栏推荐
- Redis 实战篇:巧用数据类型实现亿级数据统计
- Alternative interpretation of the macro situation: the Federal Reserve may soon end the process of raising interest rates and return to quantitative easing?
- Blueprint class view method
- R语言使用ggpubr包的gghistogram函数可视化分组箱图、添加分组均值、自定义分组色彩、添加轴须图(rug)、添加密度曲线、添加双y轴分别表示频率以及密度曲线的密度值
- 【组合逻辑电路】——显示译码器
- 源码 | OpenCV DNN + YOLOv7目标检测
- 项目知识点
- 中芯国际2018年营收33.6亿美元,14nm技术于今年量产
- JSON基本使用
- Introduction and use cases of iterator
猜你喜欢
Part of the second Shanxi Network Security Skills Competition (Enterprise Group) WP (V)
Brief introduction of yolov3 spp ultralytics model
How to meet the security needs of various cloud environments in the era of digital economy?
SAP MM 事务代码MIGO 移动类型 561保存后报错-document number ### was already assigned
Redis high availability: do you call this the principle of master-slave architecture data synchronization?
A sober assessment of the medium and long-term prospects of coinbase
Redis 日志篇:无畏宕机快速恢复的杀手锏
[combinational logic circuit] - display decoder
Jenkins, you can't play yet, slap your face no
Leetcode interview question 05.06 Integer conversion
随机推荐
finance × Yuancosmos: financial system under the integration of reality and emptiness
如何将 NFT 元数据从 IPFS 转移到智能合约中
YOLOv3-SPP-ultralytics 模型简述
cookie增删改查和异常
2022/07/19 learning notes (Day11) method overload
蓝图-类视图方法
迅速学tar命令对文件的打包压缩与解压缩
MySQL basic learning day06
Redis 核心篇:唯快不破的秘密
吉利和戴姆勒成立合资公司,将再国内生产纯电动smart!
Arrays.sort()自定义比较函数
67亿美元!瑞萨电子收购IDT获得最终审批通过!
R语言使用ggpubr包的gghistogram函数可视化分组箱图、添加分组均值、自定义分组色彩、添加轴须图(rug)、添加密度曲线、添加双y轴分别表示频率以及密度曲线的密度值
关于Bug
How to meet the security needs of various cloud environments in the era of digital economy?
Arrays. Sort() custom comparison function
robotframework实战(三)衍生——以百度搜索功能为例编写测试用例
迭代器(iterator)的简介及使用案例
[quick start tutorial 2] crazy shell · open source formation UAV - Introduction to hardware resources
[development tutorial 5] crazy shell arm function mobile phone serial port experiment tutorial