Hi everyone,
I recently planned to upgrade from LVGL 8 to LVGL 9, but I noticed in the latest release notes that the Fragment component has been removed.
In LVGL 8, I was using Fragment for page/screen management. After upgrading to LVGL 9, I found that Fragment is no longer available.
My question is: Does LVGL 9 provide any alternative for page/screen management? Or do we need to implement our own solution?
I would appreciate any guidance or suggestions!
Thank you!
Hi! Welcome to the forum.
You can use Tabview in v9+: Tab View (lv_tabview) - LVGL 9.6 documentation
Or if you want to manage screens: consider each screen as an lvgl object with children objects. Then you can load/unload screens on button callbacks for navigation, you can have an enum with and index for each screen and do screen management by index.
Can you explain in more detail what exactly you want to achieve? Maybe I can give you a more detailed guide.
Hi!
Thank you for your suggestion! I was indeed using LVGL’s fragment feature to manage different screens (like settings screen, main screen, etc.), but after upgrading to v9.6, I found this feature has been removed.
Do you have any recommended alternative? I want to achieve:
- Switching between multiple independent screens
- Similar to fragment’s “load/unload” mechanism
- Passing parameters between screens
Thank you again for your help!
For loading screens or switching between them you can use lv_screen_load and pass the screen object. See more about it here:
https://docs.lvgl.io/9.5/common-widget-features/screens.html
If you want fragment-like load/unload behavior, create screens on demand and use lv_screen_load_anim(..., auto_del = true) so the previous screen is deleted automatically after the transition.
For parameter passing, lv_screen_load dos not have a built-in parameter API. So the common approach is to pass data through your own app context, a custom screen_create(ctx, args) function, or via events/user data.
I also advise you to take a look into LVGL’s observer and subject feature:
https://docs.lvgl.io/9.5/main-modules/observer/observer.html#overview
Using subjects and observers your screen UI elements will react instantly to subject changes. It’s like a global state management for UI elements (labels, arcs, sliders etc)
Thank you for your reply!