当前位置:网站首页>LVGL 8.2 Simple Image button
LVGL 8.2 Simple Image button
2022-06-30 10:08:00 【仙剑情缘】
创建Image button
static void lv_example_imgbtn_1(void)
{
LV_IMG_DECLARE(imgbtn_left);
LV_IMG_DECLARE(imgbtn_right);
LV_IMG_DECLARE(imgbtn_mid); // image资源声明
/*Create a transition animation on width transformation and recolor.*/
static lv_style_prop_t tr_prop[] = {
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_IMG_RECOLOR_OPA, 0 };
static lv_style_transition_dsc_t tr;
lv_style_transition_dsc_init(&tr, tr_prop, lv_anim_path_linear, 200, 0, NULL);
static lv_style_t style_def;
lv_style_init(&style_def);
lv_style_set_text_color(&style_def, lv_color_white()); //文本设成白色
lv_style_set_transition(&style_def, &tr); //设置transition
/*Darken the button when pressed and make it wider*/
static lv_style_t style_pr;
lv_style_init(&style_pr);
lv_style_set_img_recolor_opa(&style_pr, LV_OPA_30); //重着色透明度为LV_OPA_30
lv_style_set_img_recolor(&style_pr, lv_color_black());//重着色颜色为黑色
lv_style_set_transform_width(&style_pr, 20); //设置宽度转变
/*Create an image button*/
lv_obj_t* imgbtn1 = lv_imgbtn_create(lv_scr_act()); //创建image button对象
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, &imgbtn_left, &imgbtn_mid, &imgbtn_right); //设置图片资源
lv_obj_add_style(imgbtn1, &style_def, 0); //添加未按下时style
lv_obj_add_style(imgbtn1, &style_pr, LV_STATE_PRESSED);//添加按下时style
lv_obj_align(imgbtn1, LV_ALIGN_CENTER, 0, 0); // 居中对齐
/*Create a label on the image button*/
lv_obj_t* label = lv_label_create(imgbtn1); //在imgbtn1对象上创建label
lv_label_set_text(label, "Button"); //设置显示文本
lv_obj_align(label, LV_ALIGN_CENTER, 0, -4); // LV_ALIGN_CENTER方式对齐
}
运行效果

边栏推荐
- 05_ Node JS file management module FS
- 移植完整版RT-Thread到GD32F4XX(详细)
- The AOV function of R language was used for repeated measures ANOVA (one intra group factor and one inter group factor) and interaction Plot function and boxplot to visualize the interaction
- Getting started with X86 - take over bare metal control
- 半钢同轴射频线的史密斯圆图查看和网络分析仪E5071C的射频线匹配校准
- 今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
- TypeScript–es5中的类,继承,静态方法
- Q-Learning笔记
- 历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并
- 技能梳理[email protected]语音模块+stm32+nfc
猜你喜欢

微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条...

Compétences Comb 27 @ Body sense Manipulator

Using LVM to resize partitions

go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)

RobotFramework学习笔记:环境安装以及robotframework-browser插件的安装

Viewing technological changes through Huawei Corps (V): smart Park

那个程序员,被打了。

IPhone address book import into Excel

mysql数据库基础:约束、标识列

WGet -- 404 not found due to spaces in URL
随机推荐
nvm、nrm、npx使用(安装、基本命令、参数、curl、wget)
7 大轻量易用的工具,给开发者减压提效,助力企业敏捷上云 | Techo Day 精彩回顾...
Leetcode question brushing (III) -- binary search (go Implementation)
我在鹅厂淘到了一波“炼丹神器”,开发者快打包
Gd32 RT thread DAC driver function
Use keil5 software to simulate and debug gd32f305 from 0
WGet -- 404 not found due to spaces in URL
[rust daily] several new libraries were released on January 23, 2021
Q-Learning笔记
Smith chart view of semi steel coaxial RF line and RF line matching calibration of network analyzer e5071c
那个程序员,被打了。
最新SCI影响因子公布:国产期刊最高破46分!网友:算是把IF玩明白了
The latest SCI impact factor release: the highest score of domestic journals is 46! Netizen: I understand if
Go -- maximum heap and minimum heap
Circuit breaker hystrixcircuitbreaker
Dyson design award, changing the world with sustainable design
Compare the maximum computing power of the Cenozoic top ant s19xp and the existing s19pro in bitland
Yixian e-commerce released its first quarterly report: adhere to R & D and brand investment to achieve sustainable and high-quality development
我的远程办公深度体验 | 社区征文
历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并