1 #include "../../lv_examples.h"
2 #if LV_USE_FLEX && LV_BUILD_EXAMPLES
3
4 /**
5 * A simple row and a column layout with flexbox
6 */
lv_example_flex_1(void)7 void lv_example_flex_1(void)
8 {
9 /*Create a container with ROW flex direction*/
10 lv_obj_t * cont_row = lv_obj_create(lv_screen_active());
11 lv_obj_set_size(cont_row, 300, 75);
12 lv_obj_align(cont_row, LV_ALIGN_TOP_MID, 0, 5);
13 lv_obj_set_flex_flow(cont_row, LV_FLEX_FLOW_ROW);
14
15 /*Create a container with COLUMN flex direction*/
16 lv_obj_t * cont_col = lv_obj_create(lv_screen_active());
17 lv_obj_set_size(cont_col, 200, 150);
18 lv_obj_align_to(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
19 lv_obj_set_flex_flow(cont_col, LV_FLEX_FLOW_COLUMN);
20
21 uint32_t i;
22 for(i = 0; i < 10; i++) {
23 lv_obj_t * obj;
24 lv_obj_t * label;
25
26 /*Add items to the row*/
27 obj = lv_button_create(cont_row);
28 lv_obj_set_size(obj, 100, LV_PCT(100));
29
30 label = lv_label_create(obj);
31 lv_label_set_text_fmt(label, "Item: %"LV_PRIu32"", i);
32 lv_obj_center(label);
33
34 /*Add items to the column*/
35 obj = lv_button_create(cont_col);
36 lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
37
38 label = lv_label_create(obj);
39 lv_label_set_text_fmt(label, "Item: %"LV_PRIu32, i);
40 lv_obj_center(label);
41 }
42 }
43
44 #endif
45