S sorex Expert Licensed User Longtime User Jun 23, 2020 #1 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.
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.
S sorex Expert Licensed User Longtime User Jun 23, 2020 #3 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: Jun 23, 2020 Upvote 0
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.
agraham Expert Licensed User Longtime User Jun 23, 2020 #4 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
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
S sorex Expert Licensed User Longtime User Jun 23, 2020 #5 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? 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)
agraham Expert Licensed User Longtime User Jun 23, 2020 #6 sorex said: ok, but did you create and display another page? Click to expand... Yes, two more. I'm using an enhanced version of Erels ThreePagesExample and it works exactly as expected. sorex said: I want it to be in the root.parent thus the B4XPage main container. Click to expand... That's where I put it, in the Root of B4XMainPage where it affects only that page - or did you mean something different? sorex said: I don't know how it will be memory wise if I need to add it to all my page Click to expand... 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
sorex said: ok, but did you create and display another page? Click to expand... Yes, two more. I'm using an enhanced version of Erels ThreePagesExample and it works exactly as expected. sorex said: I want it to be in the root.parent thus the B4XPage main container. Click to expand... That's where I put it, in the Root of B4XMainPage where it affects only that page - or did you mean something different? sorex said: I don't know how it will be memory wise if I need to add it to all my page Click to expand... 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.
S sorex Expert Licensed User Longtime User Jun 23, 2020 #7 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
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.
agraham Expert Licensed User Longtime User Jun 23, 2020 #8 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
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
S sorex Expert Licensed User Longtime User Jun 23, 2020 #9 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
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
Erel B4X founder Staff member Licensed User Longtime User Jun 24, 2020 #10 No such thing. You should set the background in each of the pages (trivial to do). A page in B4J is a separate form and in B4i it is a separate 'Page'. Upvote 0
No such thing. You should set the background in each of the pages (trivial to do). A page in B4J is a separate form and in B4i it is a separate 'Page'.
S sorex Expert Licensed User Longtime User Jun 24, 2020 #11 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
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.
agraham Expert Licensed User Longtime User Jun 24, 2020 #12 I think Erel's implication is that as it is not possible in B4J and B4i then such a feature would not be cross-platform and so doesn't really belong in B4XPages. Last edited: Jun 24, 2020 Upvote 0
I think Erel's implication is that as it is not possible in B4J and B4i then such a feature would not be cross-platform and so doesn't really belong in B4XPages.
Erel B4X founder Staff member Licensed User Longtime User Jun 24, 2020 #13 Exactly and it is also trivial to create a public sub in B4XMainPage that sets the background exactly as you want. Just call it from B4XPage_Create. Code: Copy B4XPages.MainPage.SetBackground(Root) Upvote 0
Exactly and it is also trivial to create a public sub in B4XMainPage that sets the background exactly as you want. Just call it from B4XPage_Create. Code: Copy B4XPages.MainPage.SetBackground(Root)