B4J Question Transparent B4XPages not transparent after MainPage

AVRC

New Member
Licensed User
Longtime User
I've always been able to find my answers here in the forum but this one has me stumped.

Attached is a small example of a B4XPages project that needs to be transparent.
The B4XMainPage is transparent but the next pages is not. I have all of the forms set to zero alpha in Designer.

What do I need to do to make all the pages transparent?

Main:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("TRANSPARENT")
    MainForm.Show
    Dim PagesManager As B4XPagesManager
    PagesManager.Initialize(MainForm)
    MainForm.BackColor = fx.Colors.ARGB(0, 0, 0, 0)
'    MainForm.WindowLeft = -3920
End Sub

B4XMainPage:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    introPage.Initialize
    B4XPages.AddPage("intro", introPage)
End Sub

Private Sub Button1_Click
    B4XPages.ShowPage("intro")
    'xui.MsgboxAsync("Hello world!", "B4X")
End Sub

First Page:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("IntroPage")
    B4XPages.GetNativeParent(Me).SetFormStyle("TRANSPARENT")
    Root.SetColorAndBorder(0,0,0,0)
    'load the layout to Root
End Sub
 

Attachments

  • Transparency test.zip
    10.6 KB · Views: 140

MicroDrie

Well-Known Member
Licensed User
Longtime User
I added JFX in global sub, set transparent layout loading command and added B4XPage_Appear sub with background color setting to transparent.

Make Background B4XPages form transparent:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
   [I] [/I]Private fx As JFX    ' <=== add this
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    B4XPages.GetNativeParent(Me).SetFormStyle("TRANSPARENT")    ' <=== Set transparent before layout load
    'load the layout to Root
    Root.LoadLayout("IntroPage")
    Root.SetColorAndBorder(0,0,0,0)
  
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

'    --- Make background transparent
Private Sub B4XPage_Appear
    B4XPages.GetNativeParent(Me).BackColor = fx.Colors.ARGB(0, 255, 0, 0)
End Sub

1687209954242.png
 
Upvote 0
Top