当前位置:网站首页>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

边栏推荐
- Go zero micro Service Practice Series (VIII. How to handle tens of thousands of order requests per second)
- Unity Shader - 踩坑 - BRP 管线中的 depth texture 的精度问题(暂无解决方案,推荐换 URP)
- 【STL源码剖析】迭代器
- LVGL 8.2 Simple Colorwheel
- MySQL导出sql脚本文件
- What is erdma as illustrated by Coptic cartoon?
- Matplotlib notes: contour & Contour
- Dow Jones Industrial Average
- 基于HAL库的LED驱动库
- LVGL 8.2 menu from a drop-down list
猜你喜欢

同事的接口文档我每次看着就头大,毛病多多。。。

国产自研系统的用户突破4亿,打破美国企业的垄断,谷歌后悔不迭

第一届中国数字藏品大会即将召开
![[STL source code analysis] iterator](/img/e8/7c69cf6e96ecfa053494397a21eff0.jpg)
[STL source code analysis] iterator

ArrayList与顺序表

Voir le changement technologique à travers la Légion Huawei (5): Smart Park

Dickinson's soul chooses its companion

Overview of currency

Mysql database foundation: views and variables

MySQL export SQL script file
随机推荐
超长干货 | Kubernetes命名空间详解
How can the sports app keep the end-to-side background alive to make the sports record more complete?
Pycharm项目使用pyinstalle打包过程中问题及解决方案
Pandora IOT development board learning (HAL Library) - Experiment 1 running lantern (RGB) experiment (learning notes)
Skill combing [email protected] intelligent instrument teaching aids based on 51 series single chip microcomputer
File sharing server
Using LVM to resize partitions
Remember the experience of an internship. It is necessary to go to the pit (I)
iptables目标TPROXY
Qt之实现QQ天气预报窗体翻转效果
05_ Node JS file management module FS
MATLAB image histogram equalization, namely spatial filtering
Skill combing [email protected] control a dog's running on OLED
Ant financial's written test question: what can be quantified in the requirements document? [Hangzhou multi tester] [Hangzhou multi tester \wang Sir]
敏捷开发: 超级易用水桶估计系统
【深度学习】深度学习检测小目标常用方法
MySQL导出sql脚本文件
19:00 p.m. tonight, knowledge empowerment phase 2 live broadcast - control panel interface design of openharmony smart home project
内存逃逸分析
Every time I look at my colleagues' interface documents, I get confused and have a lot of problems...