Make application background transparent?


I’m new to using LVGL and I’m having trouble making the background of my LVGL application transparent. Running my application in the simulator results in a red background, and running it in linux frame buffer results in black background.

What MCU/Processor/Board and compiler are you using?

Desktop linux

What LVGL version are you using?


What do you want to achieve?

I want the background to be transparent, so other applications rendered behind my LVGL application can be seen. This only needs to work in the frame buffer, its okay if it doesn’t work in the simulator window.

What have you tried so far?

I set the lv_obj_set_style_bg_opa value of my screen to 0 and set LV_COLOR_SCREEN_TRANSP to 1 in lv_conf.h. The application will overwrite all content in the frame buffer with a black background, but I want my application to render on top of the image that’s already in the frame buffer without deleting it.

I am assuming you are running under Linux with a GUI and you are using SDL2. If that is the case then you are not going to be able to achieve what you want. SDL2 doesn’t support it. You would need to use something like wxWidgets to handle rendering the frame buffer data to the screen. Optionally you can roll your own code for doing it as well. you would need to look at the man pages for your desktop GUI on how to do it.

Here is some information on how to do it. It is going to have limitations.

This is for Ubuntu and GNOME

I don’t think it’s impossible, as this post seemingly did it (with some difficulty):

Unfortunately they did not share how it was done.

This is what is wanting to be done right?

Yes that is the goal.

OK this can be done. If you are using x11 then you use the xGUI framework in combination with GL to achieve it.

Here is an example rendering a string using xlib