Best way to structure different “screens” that share an object?
What MCU/Processor/Board and compiler are you using?
PC Sim with platformIO
What LVGL version are you using?
What do you want to achieve?
As seen in the screenshot, the final GUI should contain a navbar + a content screen. The navbar remains constant while the content can change, something like a sticky header in a website. However, I am not able to set screen transparency and recreating the navbar when the content changes may not be ideal.
Can anyone advise what is the best way to achieve my goal?
Hello, I’m new to LVGL, and working on as application which has some similarities, and hope this might help. We have a shared header at the top, and about 20 screens which are driven by the top header menu bar, in combination with another top tab, and/or a bottom tab as needed.
This worked for me:
created a header with icons on the active screen. To use custom icons and spacing etc, I used a custom layout that calls tabs (where the tabs are hidden), instead of actually showing the tabs. Basically, clicking a navigation icon loads a tab.
then on each of the parent tabs, there are different tabs/button matrix as needed to control the content on the parent tab. On each of those tabs, I created a main container that takes up the whole tab.
3)All the pages’s objects are placed into the container so I can easily show/hide the container as needed for page navigation.
Rather than using transparency, the header is created once and stays at the top of the active screen, while tab controls and show/hide containers are used to change the content below the header.
Firstly, be aware that you can only have 1 screen loaded at any given time so your transparency experiment will not work. Secondly, everything in LVGL needs a parent (except a screen).
In order to achieve what you are after you must first create the initial page (Nav bar with Content 1) then when you switch to the next page you can reassign the parent of the Nav bar using lv_obj_set_parent to screen #2. To adjust the order of children you can use lv_obj_move_foreground/lv_obj_move_background, i.e. to move the Nav bar to the top.
I think this coupled with the @jstilley approach should give you enough options to construct your UI.
Note: transparency/opacity does work for 16bit with objects on the same screen.