diff --git a/examples/others/xml/lv_example_xml_2.c b/examples/others/xml/lv_example_xml_2.c index b4fae5b899..f037a54ac3 100644 --- a/examples/others/xml/lv_example_xml_2.c +++ b/examples/others/xml/lv_example_xml_2.c @@ -3,10 +3,44 @@ void lv_example_xml_2(void) { - lv_xml_component_register_from_file("A:lvgl/examples/others/xml/view.xml"); + lv_result_t res; + res = lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_h3.xml"); + if(res != LV_RESULT_OK) { + lv_obj_t * label = lv_label_create(lv_screen_active()); + lv_label_set_text(label, "Couldn't open the XML files."); + lv_obj_center(label); + return; + } + lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_card.xml"); lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_button.xml"); + lv_xml_component_register_from_file("A:lvgl/examples/others/xml/view.xml"); - lv_obj_t * obj = (lv_obj_t *) lv_xml_create(NULL, "view", NULL); - lv_screen_load(obj); + lv_xml_register_font(NULL, "lv_montserrat_18", &lv_font_montserrat_18); + + lv_obj_t * obj = (lv_obj_t *) lv_xml_create(lv_screen_active(), "view", NULL); + lv_obj_set_pos(obj, 10, 10); + + const char * my_button_attrs[] = { + "x", "10", + "y", "-10", + "align", "bottom_left", + "btn_text", "New button", + NULL, NULL, + }; + + lv_xml_component_unregister("my_button"); + + lv_xml_create(lv_screen_active(), "my_button", my_button_attrs); + + const char * slider_attrs[] = { + "x", "200", + "y", "-15", + "align", "bottom_left", + "value", "30", + NULL, NULL, + }; + + lv_obj_t * slider = (lv_obj_t *) lv_xml_create(lv_screen_active(), "lv_slider", slider_attrs); + lv_obj_set_width(slider, 100); } #endif diff --git a/examples/others/xml/my_button.xml b/examples/others/xml/my_button.xml index cb4519a176..bcfb69a394 100644 --- a/examples/others/xml/my_button.xml +++ b/examples/others/xml/my_button.xml @@ -8,11 +8,8 @@ - - - - - + + diff --git a/examples/others/xml/view.xml b/examples/others/xml/view.xml index ee743705dd..6eea106786 100644 --- a/examples/others/xml/view.xml +++ b/examples/others/xml/view.xml @@ -1,8 +1,39 @@ - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + +