diff --git a/examples/others/xml/view.xml b/examples/others/xml/view.xml
index 750d161030..46d064afb9 100644
--- a/examples/others/xml/view.xml
+++ b/examples/others/xml/view.xml
@@ -1,25 +1,6 @@
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/others/xml/lv_xml.c b/src/others/xml/lv_xml.c
index 019893d9c6..f24da584ab 100644
--- a/src/others/xml/lv_xml.c
+++ b/src/others/xml/lv_xml.c
@@ -37,6 +37,7 @@
#include "parsers/lv_xml_textarea_parser.h"
#include "parsers/lv_xml_keyboard_parser.h"
#include "parsers/lv_xml_arc_parser.h"
+#include "parsers/lv_xml_switch_parser.h"
#include "parsers/lv_xml_checkbox_parser.h"
#include "parsers/lv_xml_canvas_parser.h"
#include "parsers/lv_xml_calendar_parser.h"
@@ -113,6 +114,7 @@ void lv_xml_init(void)
lv_xml_widget_register("lv_textarea", lv_xml_textarea_create, lv_xml_textarea_apply);
lv_xml_widget_register("lv_keyboard", lv_xml_keyboard_create, lv_xml_keyboard_apply);
lv_xml_widget_register("lv_arc", lv_xml_arc_create, lv_xml_arc_apply);
+ lv_xml_widget_register("lv_switch", lv_xml_switch_create, lv_xml_switch_apply);
lv_xml_widget_register("lv_checkbox", lv_xml_checkbox_create, lv_xml_checkbox_apply);
lv_xml_widget_register("lv_canvas", lv_xml_canvas_create, lv_xml_canvas_apply);
lv_xml_widget_register("lv_calendar", lv_xml_calendar_create, lv_xml_calendar_apply);
diff --git a/src/others/xml/parsers/lv_xml_switch_parser.c b/src/others/xml/parsers/lv_xml_switch_parser.c
new file mode 100644
index 0000000000..5e78f9aa55
--- /dev/null
+++ b/src/others/xml/parsers/lv_xml_switch_parser.c
@@ -0,0 +1,76 @@
+/**
+ * @file lv_xml_switch_parser.c
+ *
+ */
+
+/*********************
+ * INCLUDES
+ *********************/
+#include "lv_xml_switch_parser.h"
+#if LV_USE_XML
+
+#include "../../../lvgl.h"
+#include "../../../lvgl_private.h"
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+static lv_switch_orientation_t orientation_text_to_enum_value(const char * txt);
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+void * lv_xml_switch_create(lv_xml_parser_state_t * state, const char ** attrs)
+{
+ LV_UNUSED(attrs);
+
+ void * item = lv_switch_create(lv_xml_state_get_parent(state));
+ return item;
+}
+
+void lv_xml_switch_apply(lv_xml_parser_state_t * state, const char ** attrs)
+{
+ void * item = lv_xml_state_get_item(state);
+ lv_xml_obj_apply(state, attrs); /*Apply the common properties, e.g. width, height, styles flags etc*/
+
+ for(int i = 0; attrs[i]; i += 2) {
+ const char * name = attrs[i];
+ const char * value = attrs[i + 1];
+
+ if(lv_streq("orientation", name)) lv_switch_set_orientation(item, orientation_text_to_enum_value(value));
+ }
+}
+
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+
+static lv_switch_orientation_t orientation_text_to_enum_value(const char * txt)
+{
+ if(lv_streq("auto", txt)) return LV_SWITCH_ORIENTATION_AUTO;
+ if(lv_streq("horizontal", txt)) return LV_SWITCH_ORIENTATION_HORIZONTAL;
+ if(lv_streq("vertical", txt)) return LV_SWITCH_ORIENTATION_VERTICAL;
+
+ LV_LOG_WARN("%s is an unknown value for switch's orientation", txt);
+
+ return 0; /*Return 0 in lack of a better option. */
+}
+
+#endif /* LV_USE_XML */
diff --git a/src/others/xml/parsers/lv_xml_switch_parser.h b/src/others/xml/parsers/lv_xml_switch_parser.h
new file mode 100644
index 0000000000..550a52649e
--- /dev/null
+++ b/src/others/xml/parsers/lv_xml_switch_parser.h
@@ -0,0 +1,40 @@
+/**
+ * @file lv_xml_switch_parser.h
+ *
+ */
+
+#ifndef LV_XML_SWITCH_PARSER_H
+#define LV_XML_SWITCH_PARSER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ * INCLUDES
+ *********************/
+#include "../lv_xml.h"
+#if LV_USE_XML
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * GLOBAL PROTOTYPES
+ **********************/
+
+void * lv_xml_switch_create(lv_xml_parser_state_t * state, const char ** attrs);
+void lv_xml_switch_apply(lv_xml_parser_state_t * state, const char ** attrs);
+
+/**********************
+ * MACROS
+ **********************/
+
+#endif /* LV_USE_XML */
+
+#ifdef __cplusplus
+} /*extern "C"*/
+#endif
+
+#endif /*LV_XML_SWITCH_PARSER_H*/
diff --git a/tests/ref_imgs/xml/lv_switch.png b/tests/ref_imgs/xml/lv_switch.png
new file mode 100644
index 0000000000..db270ff85a
Binary files /dev/null and b/tests/ref_imgs/xml/lv_switch.png differ
diff --git a/tests/ref_imgs_vg_lite/xml/lv_switch.png b/tests/ref_imgs_vg_lite/xml/lv_switch.png
new file mode 100644
index 0000000000..0f7c8f27a3
Binary files /dev/null and b/tests/ref_imgs_vg_lite/xml/lv_switch.png differ
diff --git a/tests/src/test_cases/xml/test_xml_switch.c b/tests/src/test_cases/xml/test_xml_switch.c
new file mode 100644
index 0000000000..e1bc530032
--- /dev/null
+++ b/tests/src/test_cases/xml/test_xml_switch.c
@@ -0,0 +1,40 @@
+#if LV_BUILD_TEST
+#include "../lvgl.h"
+
+#include "unity/unity.h"
+
+void setUp(void)
+{
+ /* Function run before every test */
+}
+
+void tearDown(void)
+{
+ /* Function run after every test */
+ lv_obj_clean(lv_screen_active());
+}
+
+
+void test_xml_switch_widget(void)
+{
+ lv_obj_t * scr = lv_screen_active();
+
+ lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN);
+ lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
+
+ lv_xml_create(scr, "lv_switch", NULL);
+
+ const char * attrs_1[] = {
+ "width", "100",
+ "height", "40",
+ "checked", "true",
+ NULL, NULL,
+ };
+
+ lv_xml_create(scr, "lv_switch", attrs_1);
+
+
+ TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_switch.png");
+}
+
+#endif
diff --git a/xmls/lv_bar.xml b/xmls/lv_bar.xml
index 209f68c118..147d0bef4d 100644
--- a/xmls/lv_bar.xml
+++ b/xmls/lv_bar.xml
@@ -11,7 +11,7 @@ Example
-
+
diff --git a/xmls/lv_switch.xml b/xmls/lv_switch.xml
new file mode 100644
index 0000000000..9c78bd1566
--- /dev/null
+++ b/xmls/lv_switch.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file