Files
lvgl/examples/others/xml/my_button.xml
T
2025-11-14 14:39:30 +08:00

43 lines
1.5 KiB
XML

<!-- A simple button that defines a show up animation for itself -->
<component>
<api>
<prop name="label_text" type="string" default="Click me" />
</api>
<styles>
<style
name="style_base"
bg_opa="100%"
bg_color="0x000044"
width="content"
height="content"
radius="10"
pad_hor="30"
pad_ver="20"
text_color="0xfff"
/>
<style name="style_pressed" recolor="0xfff" recolor_opa="20%" />
</styles>
<animations>
<!-- Fade in and move up
This animation can be played later in an event by a parent component or screen -->
<timeline name="show_up">
<animation target="self" prop="opa" start="0" end="255" duration="200" early_apply="true" />
<animation target="self" prop="bg_color" start="0xff0000" end="0x00ff00" duration="2000" early_apply="true" />
<animation target="self" prop="translate_y" start="20" end="0" duration="200" early_apply="true" />
<animation target="self" prop="width" start="0%" end="50%" duration="200" early_apply="true" />
</timeline>
</animations>
<view extends="lv_button">
<remove_style_all />
<style name="style_base" />
<style name="style_pressed" selector="pressed" />
<lv_label text="$label_text" align="center" />
<play_timeline_event target="self" timeline="show_up" />
</view>
</component>