lv_example_style_1.c 744 B

1234567891011121314151617181920212223242526272829303132
  1. #include "../lv_examples.h"
  2. #if LV_BUILD_EXAMPLES && LV_USE_IMG
  3. /**
  4. * Using the Size, Position and Padding style properties
  5. */
  6. void lv_example_style_1(void)
  7. {
  8. static lv_style_t style;
  9. lv_style_init(&style);
  10. lv_style_set_radius(&style, 5);
  11. /*Make a gradient*/
  12. lv_style_set_width(&style, 150);
  13. lv_style_set_height(&style, LV_SIZE_CONTENT);
  14. lv_style_set_pad_ver(&style, 20);
  15. lv_style_set_pad_left(&style, 5);
  16. lv_style_set_x(&style, lv_pct(50));
  17. lv_style_set_y(&style, 80);
  18. /*Create an object with the new style*/
  19. lv_obj_t * obj = lv_obj_create(lv_scr_act());
  20. lv_obj_add_style(obj, &style, 0);
  21. lv_obj_t * label = lv_label_create(obj);
  22. lv_label_set_text(label, "Hello");
  23. }
  24. #endif