Project File
Configure your LVGL Pro project with project.xml — set the LVGL version, exported code name, the display targets used to preview screens, and a hardware overlay that shows them inside a picture of the device.
project.xml is the top-level configuration file of an LVGL Pro project. It is read by the Editor, by the CLI, and by the runtime XML loader to learn the target LVGL version, the exported code's name, and the display configurations used to render screens in the preview.
project.xml lives next to globals.xml at the root of the project folder.
Recommended Project Layout
Apart from the three XML files at the root (see below), LVGL Pro doesn't enforce a folder structure, but the Editor, the tutorials, and the example projects all follow the same convention. Sticking to it keeps src_path references short and makes generated code predictable.
my_project/
├── project.xml ← target/display configuration (this file)
├── globals.xml ← shared fonts, images, subjects, consts, styles
├── translations.xml ← optional, multi-language strings
├── fonts/ ← .ttf / .bin source files referenced by globals.xml
├── images/ ← .png assets referenced by globals.xml
├── widgets/ ← custom <widget> XMLs (one file per widget)
├── components/ ← reusable <component> XMLs (one file per component)
├── screens/ ← <screen> XMLs (one file per screen)
└── custom_data/ ← optional, arbitrary files copied into the Editor previewThe three XML files (project.xml, globals.xml, translations.xml) sit at the project root; the sub-folders hold everything else. project.xml and globals.xml are required, and translations.xml is optional. Each of them belongs at the root under exactly this name: the Editor and the CLI report any of them in a sub-folder as an error, and each project has at most one translations.xml (see Translations). Any of the sub-folders can be omitted if the project doesn't use that category.
Any files placed in a custom_data/ folder are copied into the Editor preview as-is. This is useful for shipping arbitrary application or test data (e.g. a JSON fixture or a data file read by a widget at runtime) alongside the UI.
Minimal Example
The simplest valid project file declares a name, the LVGL version, and at least one <target> with a <display>:
<project name="ui" lvgl_version="9.6.0">
<targets>
<target name="target1">
<display width="800" height="480"/>
</target>
</targets>
</project>This is enough for the Editor to load the project with a given resolution. However, project.xml
supports a whole lot of useful features. Keep reading to learn them all.
Multiple Targets
To preview Screens at multiple resolutions of real hardware, declare multiple <target> elements inside <targets>.
Each target contains a <display> describing the screen size.
<project name="ui" lvgl_version="9.6.0">
<targets>
<target name="large">
<display width="800" height="480"/>
</target>
<target name="small">
<display width="480" height="320"/>
</target>
</targets>
</project>When a Screen is open in the Editor, the Preview panel shows one entry per <target>.
This is also how the Editor knows how to size a Screen's <view>.
It's also possible to conditionally use assets, styles or even views based on selected target. It's a great way to manage assets and the appearance of components separately for different targets. Learn more at Targets
Hardware Overlay
This feature requires LVGL Pro Editor v2.1 or higher.
A <display> can be shown inside a picture of the real device, so the Preview looks like the
finished product. Areas of that picture can also act as the device's physical buttons: clicking one
sends a key to the UI, so keypad navigation can be tested with the mouse, without any hardware.
To add an overlay, place an <overlay> inside the <display> of a target:
<project name="ui" lvgl_version="9.6.0">
<targets>
<target name="target1">
<display width="368" height="448">
<overlay image_src_path="images/device_frame.png" viewport_x="78" viewport_y="88">
<button_overlay name="UP" help="Move up" key="arrow_up" x="291" y="562" w="52" h="40"/>
<button_overlay name="DOWN" help="Move down" key="arrow_down" x="291" y="654" w="52" h="40"/>
<button_overlay name="LEFT" help="Move left" key="arrow_left" x="251" y="602" w="40" h="52"/>
<button_overlay name="RIGHT" help="Move right" key="arrow_right" x="343" y="602" w="40" h="52"/>
<button_overlay name="OK" help="Confirm" key="enter" x="291" y="602" w="52" h="52" color="0x2ADEF6"/>
<button_overlay name="BACK" help="Go back" key="esc" x="131" y="585" w="78" h="78" color="0xF5AB2A"/>
</overlay>
</display>
</target>
</targets>
</project>
The overlay is used only by the Editor. The image is not added to globals.xml, and nothing
about the overlay reaches the exported C code.
Since each <target> has its own <display>, each target can have its own device picture and buttons.
<overlay>
| Attribute | Required | Description |
|---|---|---|
image_src_path | yes | PNG picture of the device, relative to the project root |
viewport_x | yes | X position of the display's top-left corner inside the picture, in pixels |
viewport_y | yes | Y position of the display's top-left corner inside the picture, in pixels |
hidden | no | true hides the overlay in the Preview of screens and components without deleting it. Default: false |
The picture is shown at its own size, and the display is drawn 1:1 on top of it at
(viewport_x, viewport_y). So the screen area of the picture should be exactly as large as
the display's width × height, in pixels. The Preview's zoom scales the picture and the display together.
<button_overlay>
Each <button_overlay> is a rectangular area of the picture that works as a key when clicked.
An <overlay> can have any number of them.
| Attribute | Required | Description |
|---|---|---|
name | yes | Name of the button, e.g. OK |
help | yes | Tooltip shown when hovering the button |
key | yes | Key sent to the UI. See Keys |
x | yes | X position of the area's top-left corner, in pixels of the picture (not of the display) |
y | yes | Y position of the area's top-left corner, in pixels of the picture |
w | yes | Width of the area, in pixels |
h | yes | Height of the area, in pixels |
color | no | Color of the button's highlight, as 0xRRGGBB. Default: white |
The area itself is invisible: the picture already shows the button. It is highlighted in its color
while it is pressed, and in the calibration view.
Keys
key takes one of following special names, a single letter (a–z, A–Z) or a single digit (0–9).
The UI receives the matching LVGL key.
key | LVGL key |
|---|---|
arrow_up, arrow_down, arrow_left, arrow_right | LV_KEY_UP, LV_KEY_DOWN, LV_KEY_LEFT, LV_KEY_RIGHT |
enter | LV_KEY_ENTER |
esc | LV_KEY_ESC |
backspace | LV_KEY_BACKSPACE |
delete | LV_KEY_DEL |
tab, page_down | LV_KEY_NEXT |
page_up | LV_KEY_PREV |
space, a letter or a digit | That character |
Clicking a button is the same as pressing that key on your keyboard while the Preview has focus. The key is pressed when the mouse button goes down and released when it goes up, so holding the mouse button holds the key.
In the Preview, keys go to a keypad input device whose group is the default group. So the
focused widget gets them as usual in LVGL: tab moves the focus to the next widget, enter
clicks it, and the arrows change a slider or a roller. Your own code can also handle them with
LV_EVENT_KEY. On the device, read the physical buttons with your own keypad input driver and
send the same keys, so the UI behaves the same way as in the Preview.
Aligning the Overlay
Open project.xml to see the calibration view: the picture with the display area highlighted
in blue and each button area in its color. Use it to adjust viewport_x/viewport_y and the
buttons' x, y, w and h until they line up with the picture. This view always shows the
overlay, even if it has hidden="true".
When previewing a screen or component:
- Clicking anywhere on the picture outside the display and the buttons briefly highlights all the clickable areas.
- The overlay is not shown in Design mode or while the Inspector is on, so the display can be edited and inspected on its own.
Theme
In project.xml you can also select the LVGL Theme you would like to use:
- Simple: minimal styles for easy customization
- Default: a good looking theme to quickly get started
To set a theme use <project theme="simple"> or <project theme="default">.
If the theme is not set, default will be used.
Including Other Projects
A project can include other projects — for example a shared component library, or a common folder used by several projects. Declare them with a <folders> element in project.xml:
<project name="ui" lvgl_version="9.6.0">
<folders>
<!-- Specifying root project is optional, but allows for controlling the precedence of globals -->
<folder path="."/>
<folder path="./lib"/>
<folder path="../common"/>
</folders>
...
</project>Each <folder path="…"> points at another project folder (i.e. a folder containing its own project.xml/globals.xml). Its widgets, components, and globals become available to the including project. An included project cannot have a translations.xml: translations live only in the root project (see Translations).
Included projects may themselves declare <folders> to include further projects, but those nested inclusions are ignored — this feature is only one level deep. If root project A includes project B, and B includes project C, C is skipped and B will likely not function correctly.
Breaking change: existing projects that use a component library must be updated to include it explicitly with a <folder path="./lib"/> entry (adjusted to the library's actual path).
Relation to Other Files
globals.xml— Defines project-wide fonts, images, subjects, constants, and shared styles. See Introduction.- Screens — Use the targets declared here to choose a preview resolution. See Screens.
- Code export — The
nameattribute controls the exported project name and init function. See Using Exported C Code.
Last updated on