当前位置:网站首页>LVGL 8.2 Simple Image button
LVGL 8.2 Simple Image button
2022-06-30 10:54:00 【Fairy sword love】
establish 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 Resource statement
/*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()); // Set text to white
lv_style_set_transition(&style_def, &tr); // Set up 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); // Recolor transparency is LV_OPA_30
lv_style_set_img_recolor(&style_pr, lv_color_black());// The recolor color is black
lv_style_set_transform_width(&style_pr, 20); // Set width transition
/*Create an image button*/
lv_obj_t* imgbtn1 = lv_imgbtn_create(lv_scr_act()); // establish image button object
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, &imgbtn_left, &imgbtn_mid, &imgbtn_right); // Set up picture resources
lv_obj_add_style(imgbtn1, &style_def, 0); // Add when not pressed style
lv_obj_add_style(imgbtn1, &style_pr, LV_STATE_PRESSED);// Add when pressed style
lv_obj_align(imgbtn1, LV_ALIGN_CENTER, 0, 0); // Align center
/*Create a label on the image button*/
lv_obj_t* label = lv_label_create(imgbtn1); // stay imgbtn1 Create on object label
lv_label_set_text(label, "Button"); // Set display text
lv_obj_align(label, LV_ALIGN_CENTER, 0, -4); // LV_ALIGN_CENTER Alignment
}
Running effect

边栏推荐
- Pytorch notes: validation, model eval V.S torch. no_ grad
- Auto Seg-Loss: 自动损失函数设计
- Dow Jones Industrial Average
- LVGL 8.2 re-coloring
- LVGL8.2 Simple Checkboxes
- Time complexity and space complexity
- Input a decimal data, convert to 8, using the sequence stack
- Gd32 RT thread RTC driver function
- 运动App如何实现端侧后台保活,让运动记录更完整?
- The two e-commerce bigwigs' lacy news screens represent the return of e-commerce to normal, which will be beneficial to the real economy
猜你喜欢

MATLAB image histogram equalization, namely spatial filtering

无心剑中译狄金森《灵魂择其伴侣》

sCrypt 中的 ECDSA 签名验证

智能DNA分子纳米机器人模型来了
[email protected]+ Alibaba cloud +nbiot+dht11+bh1750+ soil moisture sensor +oled"/>Skill sorting [email protected]+ Alibaba cloud +nbiot+dht11+bh1750+ soil moisture sensor +oled

CSDN blog operation team 2022 H1 summary

List介绍

Qt之实现动效导航栏

File sharing server

Dell et Apple, deux entreprises de PC établies, se sont effondrées rapidement
随机推荐
微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条...
Didi open source agile test case management platform!
Pytorch Notebook. Nn. Batchnorm1d
Unity Shader - 踩坑 - BRP 管线中的 depth texture 的精度问题(暂无解决方案,推荐换 URP)
Memory escape analysis
前嗅ForeSpider教程:抽取数据
【深度学习】深度学习检测小目标常用方法
程序员需知的 59 个网站
[rust weekly database] num bigint - large integer
深潜Kotlin协程(十六):Channel
go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
ArrayList与顺序表
Gd32 RT thread flash driver function
Skill sorting [email protected]+adxl345+ Motor vibration + serial port output
MATLAB image histogram equalization, namely spatial filtering
DQN笔记
断路器HystrixCircuitBreaker
CSDN blog operation team 2022 H1 summary
Auto Seg-Loss: 自动损失函数设计
LVGL 8.2 Simple Colorwheel