Android Question How to show a panel above all my layout?

demasi

Active Member
Licensed User
Longtime User
Hello,
I have a custom view where I display a panel when the user clicks the custom view.
This panel must be above all my layouts view.
But the panel does not covers some buttons created in the layout file.
I tried to send the panel to front using pnl.bringtofront but this not worked too.
Thank you.

the layout has a button, and a instance of the custom view.

The example project is attached.

This is the custom view code:

B4X:
Sub Class_Globals
    Private EventName As String 'ignore
    Private CallBack As Object 'ignore
    Private mBase As Panel
    Dim pnl As Panel
End Sub

Public Sub Initialize (vCallback As Object, vEventName As String)
    EventName = vEventName
    CallBack = vCallback
End Sub

Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
    mBase = Base
    Dim parent As Panel = Base.Parent
    Base.Color = Colors.Transparent
    Dim but As Button
    but.Initialize("but")
    Base.AddView(but,0,0,Base.Width,Base.Height)
    but.Text = "Custom View - Click"
    pnl.Initialize("pnl")
    pnl.Color = Colors.Blue
    pnl.Visible = False
    parent.AddView(pnl,0,0,100%x,100%y)
    pnl.BringToFront
End Sub

Public Sub GetBase As Panel
    Return mBase
End Sub

Sub but_click
    pnl.Visible = True  
End Sub

Sub pnl_click
    pnl.Visible = False 
End Sub
 

Attachments

  • zorder.zip
    7.6 KB · Views: 148

demasi

Active Member
Licensed User
Longtime User
Thank you, @lemonisdead and @Erel.

I tried with the elevation of the panel and it worked. I tough that elevation was only to deal with shadows.

But I noted too that this only occurs in Android 5. In Android 4 it works like ever.

Is there a way to use a flat button, with no elevation at all?

I tried changing the backgroud to a drawable and was the same.

I use B4A mainly to make quizes to my first degree maths, geography and history students. They are all curious about how I make apps so fast.
I tell them that its only possible with b4A. I´m sure some of them will be programmers in the future, thanks to B4A.

The most of my apps are just for me, my daughter, and some friends. The most are games, quizes, ebooks, a lot of calculators, utilities etc.
Unfortunately all of them are in portuguese, but I will internationalize some and share with this fantastic community.

I have only one app published at Google Play, its a dates calculator, using admob. If someone want to try you may search for the publisher name CTD mobile or my name Demasi, so there´s a lot of dates calculator in the play store.

I know that this is not the place to post this, but understand this like a big "THANK YOU" for all the support you all always give me, and this community members.
 
Upvote 0

demasi

Active Member
Licensed User
Longtime User
This only happens with button, with android 5 and up. It´s a good idea to use a label as a button to avoid this elevation.
Thank you.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But I noted too that this only occurs in Android 5. In Android 4 it works like ever.
That's true. Elevation is only available when the material theme is used. However nothing bad will happen if you use elevation on older devices. It will just have no effect.

This is how the material theme looks.
 
Upvote 0
Top