Android Question How to bring panel front

Discussion in 'Android Questions' started by Nitin Joshi, Aug 11, 2019.

  1. Nitin Joshi

    Nitin Joshi 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.
     
  2. emexes

    emexes Well-Known Member 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
     
  3. Nitin Joshi

    Nitin Joshi 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.
     
  4. emexes

    emexes Well-Known Member 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.
     
  5. Nitin Joshi

    Nitin Joshi Member Licensed User

    Tried this option but it does not work...
     
  6. emexes

    emexes Well-Known Member 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
     
  7. emexes

    emexes Well-Known Member Licensed User

    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: Aug 11, 2019
  8. DonManfred

    DonManfred Expert Licensed User

    Help us helping you
    Upload a small project which shows the problem.
     
  9. emexes

    emexes Well-Known Member 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.
     
  10. Nitin Joshi

    Nitin Joshi Member Licensed User

    Elevation property worked, thanks.
     
    emexes likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice