Android Question Android 5.0.2 - Different behavior of BringToFront

FrancoisPG

Member
Licensed User
Longtime 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?
 

lemonisdead

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

FrancoisPG

Member
Licensed User
Longtime 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

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

ilan

Expert
Licensed User
Longtime User
are you using this theme in your manifest: SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
 
Upvote 0

ilan

Expert
Licensed User
Longtime 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.

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...
 
Upvote 0

ilan

Expert
Licensed User
Longtime 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?
 
Upvote 0
Top