当前位置:网站首页>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方式对齐
}
运行效果

边栏推荐
- June training (day 30) - topology sorting
- 苹果5G芯片被曝研发失败,QQ密码bug引热议,蔚来回应做空传闻,今日更多大新闻在此...
- Gd32 RT thread DAC driver function
- Curl --- the request fails when the post request parameter is too long (more than 1024b)
- Machine learning interview preparation (I) KNN
- Kernel linked list (general linked list) "list.h" simple version and individual comments
- 05_ Node JS file management module FS
- 59 websites programmers need to know
- 再测云原生数据库性能:PolarDB依旧最强,TDSQL-C、GaussDB变化不大
- GD32 RT-Thread DAC驱动函数
猜你喜欢

sCrypt 中的 ECDSA 签名验证

Migrate full RT thread to gd32f4xx (detailed)

在 sCrypt 中实现高效的椭圆曲线点加法和乘法

Musk has more than 100 million twitter fans, but he has been lost online for a week

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

How to deploy deflationary combustion destruction contract code in BSC chain_ Deploy dividend and marketing wallet contract code

Sarsa笔记

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

Yixian e-commerce released its first quarterly report: adhere to R & D and brand investment to achieve sustainable and high-quality development

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
随机推荐
Mysql database foundation: constraint and identification columns
GD32 RT-Thread RTC驱动函数
How to deploy deflationary combustion destruction contract code in BSC chain_ Deploy dividend and marketing wallet contract code
记一次实习的经历,趟坑必备(一)
Mysql database foundation: views and variables
GD32 RT-Thread flash驱动函数
Compétences Comb 27 @ Body sense Manipulator
Ant s19xp appeared in 140t, why is it called the computing power ceiling by the world
Gd32 RT thread DAC driver function
历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并
scratch绘制正方形 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月
同事的接口文档我每次看着就头大,毛病多多。。。
Typescript – classes in Es5, inheritance, static methods
Notes on numerical calculation - iterative solution of linear equations
Pandora IOT development board learning (HAL Library) - Experiment 1 running lantern (RGB) experiment (learning notes)
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
Agile Development: super easy to use bucket estimation system
ArcGIS Pro脚本工具(6)——修复CAD图层数据源
Mysql database foundation: TCL transaction control language
[rust daily] several new libraries were released on January 23, 2021