B4J Question Form Background and style Transparent

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
I enclouse an example with two files, one without buttons and the transparency is ok and another with button and the transparency is lost
Why?
Thanks
 

Attachments

  • transparent_whit_buttons.zip
    1.8 KB · Views: 172
  • transparent_whitout_buttons.zip
    1.8 KB · Views: 203

jmon

Well-Known Member
Licensed User
Longtime User
Strange indeed, but I found the solution:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("TRANSPARENT")
    MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
'    MainForm.Icon = fx.LoadImage(File.DirApp, "ico.png")
    MainForm.BackColor = fx.Colors.Transparent
    MainForm.RootPane.Style = $"-fx-background-color:transparent;"$ '<----- Add this line
    cv.Initialize("")
    x1 = 20
    y1 = 40
    x2 = 20
    y2 = 280
    bt1.Initialize("bt1")
    bt1.Text = "<"
    bt2.Initialize("bt2")
    bt2.Text = ">"
    MainForm.RootPane.AddNode(cv, x1,y1,x2,y2)
    cv.DrawLine(x1,y1,x2,y2,fx.Colors.Black,1.0)
    MainForm.RootPane.AddNode(bt1, 10, 340, 50, 40)
    MainForm.RootPane.AddNode(bt2, 70, 340, 50, 40)
    MainForm.Show
End Sub

just add
B4X:
MainForm.RootPane.Style = $"-fx-background-color:transparent;"$
 
Upvote 0
Top