Android Question How to bring panel front

Nitin Joshi

Active Member
Licensed User
In my project there are several buttons and one panel. Once I click a button, I make panel visible and its working, however, panel is visible behind buttons. I want panel should be in front. Please help to know the reason.
 

emexes

Expert
Licensed User
In Designer, drag the panel/view towards the bottom of the Views Tree tab on the left side of the IDE.

upload_2019-8-12_2-7-20.png
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Activity is loading 2 layouts, Layout 1 & Layout 2. When activity is initialized, I am loading Layout 1 & Layout 2 activity and after pressing button (Layout 2) making panel visible (Layout 1). Its visible but behind buttons.
 
Upvote 0

emexes

Expert
Licensed User
upload_2019-8-12_2-23-50.png


There is a corresponding SendToBack method/property too.

Or you could play with the Elevations, but I think that has other side effects eg parallax.
 
Upvote 0

emexes

Expert
Licensed User
And/or you might want to consider getting the existing layouts off the screen altogether before loading a new layout. One way is to have each of your sublayouts contained on a single panel, and then you can (I think) hide/reveal that panel and its contents by changing just the one .Visible property. Or you could move the non-panels off-screen to hide them, eg .Left = 10000, and then likewise .Left = 0 to reveal/restore them.

Or if you won't be needing the old panel again, you could do this:

upload_2019-8-12_2-27-53.png
 
Upvote 0

emexes

Expert
Licensed User
Tried this option but it does not work...
Probably it is sending the view to the back of its parent, and the parent is still hiding whatever it is you can't see.

Or to the front of its parent, which remains behind whatever is obscuring it.
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
If you have multiple screens in the one activity, then consider grouping each screen onto its own panel, and loading each layout into its corresponding screen panel.

Then (I am pretty sure) you can make an entire screen visible or hidden just with the one Panel.Visible = True/False.

And just keep all the screens hidden, except for the screen that is currently active and you want displayed.

But watch out for duplicates of views, eg if two layouts both have a Save button, make sure the two buttons have different names.
 
Upvote 0
Top