Android Question B4XPages background panel

sorex

Expert
Licensed User
Longtime User
Hello,

Are there any plans for an additional background panel/layer where we can add/set our background image/color to?
(maybe it's already accessible but I didn't see if)

The game I'm modding has a general image and the rest of the 'pages' are overlayed.

It would be nice if this image could be added within the B4XPages as first/most deep layer.
Now I create it on the activity in the main module before the page manager is initialized.
 
that's the first thing I tried, a-man.

but it doesn't work.

as long as I don't use addpage & showpage it's visible by adding it to root1 in _Created.

it's plain black when a page is added and shown.

adding it straight to the activity shows that the page is transparent tho.

I am thinking that it's added to the default page and not the actual root panel.


Edit: the above is true. the background shows when displaying the main page but that gets hidden when showing another one.
 
Last edited:
Upvote 0
I checked that I could put both a background colour and an image on Root before I posted.
B4X: Copy
Private Sub B4XPage_Created (Root1 As B4XView)   
    Root = Root1
    'load the layout to Root - we don't here as we have a Drawer
    Root.LoadLayout("Login")
    Root.Color = Colors.Red
I also checked it works if you use a Drawer and load the layout into its centre panel
 
Upvote 0
ok, but did you create and display another page?

I want it to be in the root.parent thus the B4XPage main container.

I don't know how it will be memory wise if I need to add it to all my pages as workaround (or the straight activity method)
 
Upvote 0
ok, but did you create and display another page?
Yes, two more. I'm using an enhanced version of Erels ThreePagesExample and it works exactly as expected.

I want it to be in the root.parent thus the B4XPage main container.
That's where I put it, in the Root of B4XMainPage where it affects only that page - or did you mean something different?

I don't know how it will be memory wise if I need to add it to all my page
For a colour - nothing. For an image you could try loading it once and reusing the Bitmap on other pages. I'll try that tomorrow as I'm now off for a shower and then dinner.
 
Upvote 0
what I want is a straight forward method in B4XPages to have a background (color, image, gradient or something else that can be constructed via designer/code)
that's visible on all pages.

just an extra panel that's at the outer "back" will do unless there is another way that gives us access to the real root panel and not just the current page root.
 
Upvote 0
In Main
B4X: Copy
Sub Activity_Create(FirstTime As Boolean)
    ...   
    Dim bmpd As BitmapDrawable
    bmpd.Initialize( xui.LoadBitmapResize(File.DirAssets, "colors-icon.png", 500dip, 500dip, True))   
    Activity.Background = bmpd
End Sub
 
Upvote 0
indeed, that's a way to get it working as mentioned above and I'll use that as a temp. workaround.

but this is a feature that should be part of the B4XPages imho then there's no need to put that code in the main module and (called from) outside the shared classes.

something like b4xpages.rootpanel or .backgroundpanel
 
Upvote 0
I know that but it's like letting your house painted room by room by 10 different companies instead of doing your entire house at once by 1.

Please consider it as a feature request/improvement as it will make things a lot easier for everyone as it can be set in the default page init sub
instead of doing it in the main module with a shared sub call where we then have to take care of the activity/page differences aswell.
 
Upvote 0

Similar Threads

Replies
8
Views
17K
Replies
2
Views
13K
Replies
22
Views
42K
  • Locked
  • Article Article
Replies
4
Views
23K
Back
Top