Android Question Layout as Overlay (an its subsequent removal)

antedeluvian

Member
Licensed User
Longtime User
According to the book "B4A - Rapid Android App Development using BASIC " (P126)


Layout as Overlay
You can also call a second layout from within the first Activity, using Activity.LoadLayout("Layout2"). In this case the second layout will be seen floating above the first. To hide parts of the first, the second must have opaque panels (Alpha set to 255). This might be used to show a menu floating over the main layout.

Elsewhere it also says it also can be done with Panel.LoadLayout("Layout2").

Yet I cannot find any example anywhere of how to reverse this, i.e. turn off the layout once you are done with the second layout. I Know how to achieve this effect by a declaring panel and making it invisible/visible, but how do you do it as described?
 

antedeluvian

Member
Licensed User
Longtime User
You need to load the layout to a panel and then either hide the panel or remove it with Panel.RemoveView.

Thanks

I created a panel almost exactly as described in your post "List with two columns and a checkbox" ( https://www.b4x.com/android/forum/threads/list-with-two-columns-and-a-checkbox.7221/#post41354 ). When I make the panel invisible, the buttons on the base layout beneath the invisible panel do not react to touch. Is there some setting that I can change to allow me to activate those buttons?
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
What works for me is to create the overlay layout with all views under one main panel, then in the activity call Activity.LoadLayout("overlay"). Then to remove I call the overlay's panel remove code: pnlOverlay.RemoveAllViews, then call pnlOverlay.RemoveView. I'm not sure if the RemoveAllViews is actually necessary, but I do it to ensure there aren't any memory leaks.
 
Upvote 0

antedeluvian

Member
Licensed User
Longtime User
Thanks

I created a panel almost exactly as described in your post "List with two columns and a checkbox" ( https://www.b4x.com/android/forum/threads/list-with-two-columns-and-a-checkbox.7221/#post41354 ). When I make the panel invisible, the buttons on the base layout beneath the invisible panel do not react to touch. Is there some setting that I can change to allow me to activate those buttons?

I found a solution- as in the example the panel is associated with (I am not sure of the exact terminology here) a scrollview (pnl = ScrollView1.Panel). Bringing the panel to the front or sending it to the back back does nothing, but if I send the scrollview to the back (Scrollview1.SendToBack), and make the panel invisible (pnl.Visible=False) the underlying buttons become active. I just wonder if there is a better way to do this.
 
Upvote 0
Top