当前位置: 首页 > news >正文

使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第二十一讲)

Tabview(选项卡)对象可用于组织选项卡中的内容。选项卡对象是由其他控件组件而成的:
• 主容器:Base Widget。
• 选项卡按钮:一个带有:ref:lv_button的:ref:base_widget。
• 选项卡的容器:Base Widget。
• 选项卡的内容:Base Widget。
选项卡栏可以位于选项卡控件的顶部、底部、左侧和右侧。可以通过单击选项卡栏中的按钮或在选项卡标签上水平滑动来切换选项卡标签。以下是Gui Guider中的选项卡控件的默认图:
在这里插入图片描述
以下是通过平台软件设置所改变后的样式:
在这里插入图片描述
以下是具体的代码,以及函数的使用:
//Write codes screen_1_tabview_1
//创建标签视图
ui->screen_1_tabview_1 = lv_tabview_create(ui->screen_1, LV_DIR_LEFT, 50);
//设置位置
lv_obj_set_pos(ui->screen_1_tabview_1, 37, 33);
//设置大小
lv_obj_set_size(ui->screen_1_tabview_1, 401, 390);
//禁用标签视图的滚动条
lv_obj_set_scrollbar_mode(ui->screen_1_tabview_1, LV_SCROLLBAR_MODE_OFF);

//Write style for screen_1_tabview_1, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
//设置透明度

lv_obj_set_style_bg_opa(ui->screen_1_tabview_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置标签颜色
lv_obj_set_style_text_color(ui->screen_1_tabview_1, lv_color_hex(0x4d4d4d), LV_PART_MAIN|LV_STATE_DEFAULT);
//设置字体
lv_obj_set_style_text_font(ui->screen_1_tabview_1, &lv_font_montserratMedium_12, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置文本不透明度
lv_obj_set_style_text_opa(ui->screen_1_tabview_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置文本字符间距
lv_obj_set_style_text_letter_space(ui->screen_1_tabview_1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置文本行间距
lv_obj_set_style_text_line_space(ui->screen_1_tabview_1, 16, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置边框宽度
lv_obj_set_style_border_width(ui->screen_1_tabview_1, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置边框透明度
lv_obj_set_style_border_opa(ui->screen_1_tabview_1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置边框颜色为灰色
lv_obj_set_style_border_color(ui->screen_1_tabview_1, lv_color_hex(0x737373), LV_PART_MAIN|LV_STATE_DEFAULT);
//设置边框四周可见
lv_obj_set_style_border_side(ui->screen_1_tabview_1, LV_BORDER_SIDE_FULL, LV_PART_MAIN|LV_STATE_DEFAULT);
//设置圆角半径
lv_obj_set_style_radius(ui->screen_1_tabview_1, 9, LV_PART_MAIN|LV_STATE_DEFAULT);
//禁用阴影
lv_obj_set_style_shadow_width(ui->screen_1_tabview_1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

//Write style state: LV_STATE_DEFAULT for &style_screen_1_tabview_1_extra_btnm_main_default
//设置Tab按钮的样式
static lv_style_t style_screen_1_tabview_1_extra_btnm_main_default;
ui_init_style(&style_screen_1_tabview_1_extra_btnm_main_default);

lv_style_set_bg_opa(&style_screen_1_tabview_1_extra_btnm_main_default, 255);
lv_style_set_bg_color(&style_screen_1_tabview_1_extra_btnm_main_default, lv_color_hex(0x9ce8ff));
lv_style_set_bg_grad_dir(&style_screen_1_tabview_1_extra_btnm_main_default, LV_GRAD_DIR_NONE);
lv_style_set_border_width(&style_screen_1_tabview_1_extra_btnm_main_default, 0);
lv_style_set_radius(&style_screen_1_tabview_1_extra_btnm_main_default, 8);
lv_obj_add_style(lv_tabview_get_tab_btns(ui->screen_1_tabview_1), &style_screen_1_tabview_1_extra_btnm_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);

//Write style state: LV_STATE_DEFAULT for &style_screen_1_tabview_1_extra_btnm_items_default
//设置Tab按钮项的样式
static lv_style_t style_screen_1_tabview_1_extra_btnm_items_default;
ui_init_style(&style_screen_1_tabview_1_extra_btnm_items_default);

lv_style_set_text_color(&style_screen_1_tabview_1_extra_btnm_items_default, lv_color_hex(0x291f1f));
lv_style_set_text_font(&style_screen_1_tabview_1_extra_btnm_items_default, &lv_font_Acme_Regular_16);
lv_style_set_text_opa(&style_screen_1_tabview_1_extra_btnm_items_default, 255);
lv_obj_add_style(lv_tabview_get_tab_btns(ui->screen_1_tabview_1), &style_screen_1_tabview_1_extra_btnm_items_default, LV_PART_ITEMS|LV_STATE_DEFAULT);

//Write style state: LV_STATE_CHECKED for &style_screen_1_tabview_1_extra_btnm_items_checked
//设置选中样式
static lv_style_t style_screen_1_tabview_1_extra_btnm_items_checked;
ui_init_style(&style_screen_1_tabview_1_extra_btnm_items_checked);

lv_style_set_text_color(&style_screen_1_tabview_1_extra_btnm_items_checked, lv_color_hex(0x007185));
lv_style_set_text_font(&style_screen_1_tabview_1_extra_btnm_items_checked, &lv_font_Alatsi_Regular_18);
lv_style_set_text_opa(&style_screen_1_tabview_1_extra_btnm_items_checked, 255);
lv_style_set_border_width(&style_screen_1_tabview_1_extra_btnm_items_checked, 4);
lv_style_set_border_opa(&style_screen_1_tabview_1_extra_btnm_items_checked, 255);
lv_style_set_border_color(&style_screen_1_tabview_1_extra_btnm_items_checked, lv_color_hex(0x007185));
lv_style_set_border_side(&style_screen_1_tabview_1_extra_btnm_items_checked, LV_BORDER_SIDE_RIGHT);
lv_style_set_radius(&style_screen_1_tabview_1_extra_btnm_items_checked, 4);
lv_style_set_bg_opa(&style_screen_1_tabview_1_extra_btnm_items_checked, 0);
lv_obj_add_style(lv_tabview_get_tab_btns(ui->screen_1_tabview_1), &style_screen_1_tabview_1_extra_btnm_items_checked, LV_PART_ITEMS|LV_STATE_CHECKED);//Write codes 布局
ui->screen_1_tabview_1_tab_1 = lv_tabview_add_tab(ui->screen_1_tabview_1,"布局");
lv_obj_t * screen_1_tabview_1_tab_1_label = lv_label_create(ui->screen_1_tabview_1_tab_1);
lv_label_set_text(screen_1_tabview_1_tab_1_label, "垂直布局\n水平布局");//Write codes 尺寸
ui->screen_1_tabview_1_tab_2 = lv_tabview_add_tab(ui->screen_1_tabview_1,"尺寸");
lv_obj_t * screen_1_tabview_1_tab_2_label = lv_label_create(ui->screen_1_tabview_1_tab_2);
lv_label_set_text(screen_1_tabview_1_tab_2_label, "宽度:\n长度:");//Write codes 朝向
ui->screen_1_tabview_1_tab_3 = lv_tabview_add_tab(ui->screen_1_tabview_1,"朝向");
lv_obj_t * screen_1_tabview_1_tab_3_label = lv_label_create(ui->screen_1_tabview_1_tab_3);
lv_label_set_text(screen_1_tabview_1_tab_3_label, "居中\n向左对齐\n向右对齐");

下一期讲其他控件的基本使用。

本文章由威三学社出品
对课程感兴趣可以私信联系


文章转载自:
http://arvo.hfytgp.cn
http://avoir.hfytgp.cn
http://biopoiesis.hfytgp.cn
http://cautelous.hfytgp.cn
http://arista.hfytgp.cn
http://castoff.hfytgp.cn
http://autecological.hfytgp.cn
http://bajan.hfytgp.cn
http://carillonneur.hfytgp.cn
http://aigret.hfytgp.cn
http://brno.hfytgp.cn
http://cadetship.hfytgp.cn
http://aortography.hfytgp.cn
http://castigator.hfytgp.cn
http://chrematistics.hfytgp.cn
http://arboraceous.hfytgp.cn
http://afterlight.hfytgp.cn
http://buoyage.hfytgp.cn
http://animalization.hfytgp.cn
http://abortionism.hfytgp.cn
http://canonicate.hfytgp.cn
http://bromouracil.hfytgp.cn
http://ceiba.hfytgp.cn
http://angelina.hfytgp.cn
http://annihilationism.hfytgp.cn
http://chemoceptor.hfytgp.cn
http://acouophonia.hfytgp.cn
http://aurification.hfytgp.cn
http://benumbed.hfytgp.cn
http://californicate.hfytgp.cn
http://www.dtcms.com/a/280625.html

相关文章:

  • 【PDF识别改名】使用京东云OCR完成PDF图片识别改名,根据PDF图片内容批量改名详细步骤和解决方案
  • 同样是“跳转”,为何forward地址栏不变,redirect会变?
  • RNN、GRU 与 LSTM 计算成本深入对比
  • 基于光场相机的激光增材制造熔池温度场原位多眼监测​​
  • 【zynq7020】PL的“Hello LED”
  • FPGA高端图像ISP培训课程,提供工程源码+视频教程+FPGA开发板
  • Softhub软件下载站实战开发(十八):软件分类展示
  • 使用LNMP一键安装包安装PHP、Nginx、Redis、Swoole、OPcache
  • Vmware中安装的CentOS7如何扩展硬盘大小
  • 语言模型玩转3D生成:LLaMA-Mesh开源项目
  • 【鸿蒙HarmonyOS】鸿蒙app开发入门到实战教程(二):封装自定义可复用组件
  • 前端面试专栏-工程化:25.项目亮点与技术难点梳理
  • 手搓RAG
  • 知识增强型Agent开发新范式:基于ERNIE-4.5的检索增强生成架构实践
  • 力扣-使用双指针的方法的题们(持续更新中。。。
  • NipaPlay(视频播放器) v1.3.24 绿色版
  • ubuntu22.04谷歌浏览器中文输入法bug
  • 非实时的防控场景
  • 其他常见 HTTP 方法
  • redisson 设置了过期时间,会自动续期吗
  • 论文略读:QM-ARC: QoS-aware Multi-tier Adaptive Cache Replacement Strategy
  • 2025华为ODB卷-任务总执行时长-三语言题解
  • 图灵在二战期间是如何破译德国军用密码的?
  • 虚拟主机CPU占用100导致打不开的一次处理
  • 网络基础协议综合实验
  • GNU Radio连接X310运行报错
  • 【赵渝强老师】大数据交换引擎Sqoop
  • 实测两款效率工具:驾考刷题和证件照处理的免费方案
  • 【历史人物】【李白】生平事迹
  • deepseekAI对接大模型的网页PHP源码带管理后台(可实现上传分析文件)