B4J Question [SOLVED] Splash screen doesn't stay transparent if views are added to the mainform?

jroriz

Active Member
Licensed User
Longtime User
I used the example of the splash screen, but starting from a button.
The background is no longer transparent.

I noticed that this is because I added the button to the mainform.

Does anyone know why the image has not transparent anymore?

I took exactly the example of the link below. I only decreased the size of the mainform, I added the button and the sub click.
https://www.b4x.com/android/forum/threads/splash-screen.82557/#content

Here is the code with the changes highlighted:

B4X:
#Region Project Attributes
    #MainFormWidth: 300
    #MainFormHeight: 300
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
'    ShowSplashScreen
'    Wait For Splash_Complete
    MainForm.Show
    
    Dim b As Button
    b.Initialize("button")
    b.Text = "click"
    MainForm.RootPane.AddNode(b,130,100,50,50)
End Sub

Sub button_click
    ShowSplashScreen
    Wait For Splash_Complete
End Sub

Sub ShowSplashScreen
    Dim sp As Form
    sp.Initialize("sp", 600, 600)
    sp.SetFormStyle("TRANSPARENT")
    sp.BackColor = fx.Colors.Transparent
    CSSUtils.SetBackgroundImage(sp.RootPane, File.DirAssets, "B4R_512_512_transparent.png")
    sp.Show
    sp.RootPane.Alpha = 0
    sp.RootPane.SetAlphaAnimated(500, 1)
    Wait For (sp.RootPane) sp_AnimationCompleted
    Sleep(3000)
    sp.RootPane.SetAlphaAnimated(1000, 0)
    Wait For (sp.RootPane) sp_AnimationCompleted
    sp.Close
    CallSubDelayed(Me, "Splash_Complete")
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
 
Top