22 * @file lv_example_imagebutton.c
33 */
44
5- #include ".. /lv_examples.h"
5+ #include <examples_ed /lv_examples.h>
66
77/**
88 * @title Image button
1515 */
1616void lv_example_imagebutton (void )
1717{
18+ LV_IMAGE_DECLARE (imgbtn_left );
19+ LV_IMAGE_DECLARE (imgbtn_mid );
20+ LV_IMAGE_DECLARE (imgbtn_right );
21+
1822 static lv_style_t style_pressed ;
1923
2024 static bool inited = false;
@@ -28,6 +32,19 @@ void lv_example_imagebutton(void)
2832 inited = true;
2933 }
3034
31- lv_screen_active ();
35+ lv_obj_t * screen = lv_screen_active ();
36+
37+ lv_obj_t * lv_imagebutton_0 = lv_imagebutton_create (screen );
38+ lv_obj_set_width (lv_imagebutton_0 , 160 );
39+ lv_obj_set_align (lv_imagebutton_0 , LV_ALIGN_CENTER );
40+ lv_obj_add_style (lv_imagebutton_0 , & style_pressed , LV_STATE_PRESSED );
41+ lv_imagebutton_set_src_left (lv_imagebutton_0 , LV_IMAGEBUTTON_STATE_RELEASED , & imgbtn_left );
42+ lv_imagebutton_set_src_mid (lv_imagebutton_0 , LV_IMAGEBUTTON_STATE_RELEASED , & imgbtn_mid );
43+ lv_imagebutton_set_src_right (lv_imagebutton_0 , LV_IMAGEBUTTON_STATE_RELEASED , & imgbtn_right );
44+ lv_obj_t * lv_label_0 = lv_label_create (lv_imagebutton_0 );
45+ lv_obj_set_align (lv_label_0 , LV_ALIGN_CENTER );
46+ lv_label_set_text (lv_label_0 , "Press" );
47+ lv_obj_set_style_text_color (lv_label_0 , lv_color_hex (0xffffff ), 0 );
48+ lv_obj_set_y (lv_label_0 , -3 );
3249}
3350
0 commit comments