Android Question Android 5.0.2 - Different behavior of BringToFront

Discussion in 'Android Questions' started by FrancoisPG, Jul 27, 2015.

  1. FrancoisPG

    FrancoisPG Member Licensed User

    I have recently installed Android 5.0.2 on my phone and I have now discovered a problem with one of the apps I have developed. In my app I am displaying 3 buttons and under certain circumstances, I would like to display a panel with different buttons where the user has to make a selection, before selecting one of the 3 buttons.

    The problem I got now is that the original buttons remains in front of the panel.

    At startup I use the following 2 lines:
    pnlLearner.Visible = False
    pnlLearner.SendToBack​

    When I decide to display the panel I would just reversed the above:
    pnlLearner.Visible = True
    pnlLearner.BringToFront
    The only way I can solve this is to set the Visible state of the buttons to False when I want to display the panel. Is there a different behavior of BringToFront or was I just lucky before?
     
  2. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Hello François,
    It seems that starting from Lollipop, Buttons views z-order is always on top. So, hidding the Buttons views seems to be the right solution for you
     
  3. FrancoisPG

    FrancoisPG Member Licensed User

    Thank you, I think I got some work to do because i might have done the same in other apps!
     
  4. ilan

    ilan Expert Licensed User

    are you using this theme in your manifest: SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
     
  5. NJDude

    NJDude Expert Licensed User

    No need for that, a workaround is to add the buttons to a panel exactly the same size as the buttons, then the BringToFront and SendToBack works perfectly.
     
  6. ilan

    ilan Expert Licensed User

    i had a similar problem with *.bringtofront in my app when i tried it on android 5+, after adding this line the problem was solved...
     
  7. NJDude

    NJDude Expert Licensed User

    Yes, it "solves" the problem but you don't get the "Material" theme, with my workaround you do.
     
  8. ilan

    ilan Expert Licensed User

    1, this line will solve also other issues in android 5+

    2, if he have only 6 buttons and he want to show 3 and hide the other 3 buttons then ok he can use another panel for that but if he have 20-30 buttons then why should he work hard if he can solve it with one simple line in the manifest?
     
Loading...