B4J Question Form BackColor Transparency

CosmicFlux

Member
Hi,

I'm trying to give a form a transparent background with:

B4X:
MainForm.BackColor = fx.Colors.Transparent

but it's not applying. The form still shows the default back color. I'm also using it with a SetFormStyle of Transparent, in case that has any bearing?

I managed to achieve the effect by using the Designer to set the form to transparent there and then use a panel in its place, but this seems a bit hacky...
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Try this:

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1

    MainForm.SetFormStyle("TRANSPARENT")
    MainForm.RootPane.As(B4XView).Color = xui.Color_Transparent
    MainForm.BackColor = fx.Colors.Transparent
    
    Dim Btn As Button
    Btn.Initialize("Btn")
    Btn.Text = "Close"
    MainForm.RootPane.AddNode(Btn,100,100,150,30)
    
    
'    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
End Sub

Sub Btn_Click
    ExitApplication
End Sub
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…