1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/examples/styles/lv_example_style_1.c

32 lines
752 B
C
Raw Permalink Normal View History

2021-04-08 13:07:48 +02:00
#include "../lv_examples.h"
2023-12-13 21:23:08 +01:00
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
2021-02-19 14:47:32 +01:00
/**
2021-05-27 11:50:04 +02:00
* Using the Size, Position and Padding style properties
2021-02-19 14:47:32 +01:00
*/
void lv_example_style_1(void)
{
static lv_style_t style;
lv_style_init(&style);
lv_style_set_radius(&style, 5);
2021-02-19 14:47:32 +01:00
/*Make a gradient*/
lv_style_set_width(&style, 150);
lv_style_set_height(&style, LV_SIZE_CONTENT);
2021-02-19 14:47:32 +01:00
lv_style_set_pad_ver(&style, 20);
lv_style_set_pad_left(&style, 5);
2021-02-19 14:47:32 +01:00
lv_style_set_x(&style, lv_pct(50));
lv_style_set_y(&style, 80);
2021-05-27 11:50:04 +02:00
/*Create an object with the new style*/
lv_obj_t * obj = lv_obj_create(lv_screen_active());
lv_obj_add_style(obj, &style, 0);
2021-05-27 11:50:04 +02:00
lv_obj_t * label = lv_label_create(obj);
lv_label_set_text(label, "Hello");
2021-02-19 14:47:32 +01:00
}
#endif