当前位置:网站首页>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
边栏推荐
- The precision problem of depth texture in unity shader - stepping pit - BRP pipeline (there is no solution, it is recommended to replace URP)
- CP2112使用USB转IIC通信教学示例
- ArcGIS PRO + PS vectorized land use planning map
- LVGL 8.2 Checkboxes as radio buttons
- 05_Node js 文件管理模块 fs
- [STL source code analysis] container (to be supplemented)
- Gd32 RT thread flash driver function
- Collectors. Tomap application
- Pytorch notes: validation, model eval V.S torch. no_ grad
- Time complexity and space complexity
猜你喜欢
智能DNA分子纳米机器人模型来了
scratch绘制正方形 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月
Pytorch Notebook. Nn. Batchnorm1d
7 大轻量易用的工具,给开发者减压提效,助力企业敏捷上云 | Techo Day 精彩回顾...
pytorch 筆記 torch.nn.BatchNorm1d
Deep dive kotlin synergy (16): Channel
The precision problem of depth texture in unity shader - stepping pit - BRP pipeline (there is no solution, it is recommended to replace URP)
Matplotlib notes: contour & Contour
小程序中读取腾讯文档的表格数据
焕发青春的戴尔和苹果夹击,两大老牌PC企业极速衰败
随机推荐
LVGL 8.2 Drop down in four directions
[rust daily] several new libraries were released on January 23, 2021
Typescript – classes in Es5, inheritance, static methods
[机缘参悟-34]:光锥之内皆命运
59 websites programmers need to know
LVGL 8.2 Checkboxes as radio buttons
List introduction
Pandora IOT development board learning (HAL Library) - Experiment 1 running lantern (RGB) experiment (learning notes)
Deep dive kotlin synergy (18): hot and cold data flow
苹果高管公然“开怼”:三星抄袭 iPhone,只加了个大屏
Overview of currency
Agile Development: super easy to use bucket estimation system
ArcGIS PRO + PS vectorized land use planning map
Ionic4 drag the ion reorder group component to change the item order
软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题
Dell et Apple, deux entreprises de PC établies, se sont effondrées rapidement
深潜Kotlin协程(十七):演员
Gd32 RT thread RTC driver function
[STL source code analysis] container (to be supplemented)
SGD有多种改进的形式,为什么大多数论文中仍然用SGD?