当前位置:网站首页>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
边栏推荐
- [STL source code analysis] container (to be supplemented)
- Matplotlib notes: contour & Contour
- Viewing technological changes through Huawei Corps (V): smart Park
- The intelligent DNA molecular nano robot model is coming
- 20万奖金池!【阿里安全 × ICDM 2022】大规模电商图上的风险商品检测赛火热报名中!...
- Sarsa笔记
- Foresniffer tutorial: extracting data
- 敏捷开发: 超级易用水桶估计系统
- Android 开发面试真题进阶版(附答案解析)
- Anhui "requirements for design depth of Hefei fabricated building construction drawing review" was printed and distributed; Hebei Hengshui city adjusts the pre-sale license standard for prefabricated
猜你喜欢
DQN笔记
sCrypt 中的 ECDSA 签名验证
软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题
历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并
Every time I look at my colleagues' interface documents, I get confused and have a lot of problems...
matplotlib 笔记: contourf & contour
第一届中国数字藏品大会即将召开
[deep learning] common methods for deep learning to detect small targets
MATLAB image histogram equalization, namely spatial filtering
MySQL export SQL script file
随机推荐
科普达人丨漫画图解什么是eRDMA?
内存逃逸分析
Kernel linked list (general linked list) "list.h" simple version and individual comments
在IPhone12的推理延迟仅为1.6 ms!Snap等详析Transformer结构延迟,并用NAS搜出移动设备的高效网络结构...
Collectors.toMap应用
ArrayList与顺序表
运动App如何实现端侧后台保活,让运动记录更完整?
Deep dive kotlin synergy (16): Channel
MATLAB image histogram equalization, namely spatial filtering
& and - > priority
[deep learning] common methods for deep learning to detect small targets
超长干货 | Kubernetes命名空间详解
无心剑中译狄金森《灵魂择其伴侣》
透过华为军团看科技之变(五):智慧园区
The intelligent DNA molecular nano robot model is coming
滴滴开源敏捷测试用例管理平台!
苹果高管公然“开怼”:三星抄袭 iPhone,只加了个大屏
File sharing server
matplotlib 笔记: contourf & contour
Pytorch notes: validation, model eval V.S torch. no_ grad