B4J Question Anchorpane background image

billmoultrie

Member
Licensed User
Longtime User
Hi

I am trying to put a background image on the anchorpage.

I use the following code.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("main") 'Load the layout file.
    MainForm.Resizable = True

    MainForm.WindowHeight = 650
    MainForm.WindowWidth = 800
   
    Version = "Ver 2.5"
   
    MainForm.Title="CapConn "&Version   

     MainForm.RootPane.Style = "-fx-background-image:url('" & File.GetUri(File.DirAssets, "rain.jpg") & "');"
    
    MainForm.Show

If I run this in debug it works every time.
If I run it in release it says 'Asset rain.jpg not found'.

Any ideas?
 

stevel05

Expert
Licensed User
Longtime User
If you are using the Visual designer, you can add the background image there.

Add the image to the Files List (Tools/Files in the visual designer) then select Background BitmapDrawable and select the Image file.

Works in Debug and Release.

Your code also works for me , but the image doesn't automatically get scaled
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…