Android Question Button not hidden by Panel[ Q. No answer, but alternatives OK]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

I have a problem app with buttons not hidden. I have a panel set to Elevation of two, some buttons are hidden some are not.
Buttons that I operate immediately before the panel is brought to the front are not hidden.
If I set the panel elevation higher than two the labels on the panel are hidden.

Attached is a mock-up example that demonstrates the problem. [The real app too big.]
In the example the button Const brings PnlView to the front and a listview is built on it. Three buttons and labels are hidden but the Const button is not hidden
The buttons are parented by the activity.

Sorry about the example being so large but I built it to trace a number of issues

Any thoughts greatly appreciated.

Regards Roger
 

Attachments

  • BtnExample.zip
    153.2 KB · Views: 128

JohnC

Expert
Licensed User
Longtime User
I can't get your example working because I am using an older version of B4A.

But I do see that the panel elevations are set to "2".

Did you try setting them to 3 as mentioned in this post:

 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
John,
As I said in the post if I set the panels elevation above 2 the labels are hidden.

Sorry, lost thread juggling phone calls.

I've been round the rose bush a few times with this one.

Thanks for try. Treat yourself, upgrade your b4a.

Regards Roger
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I misread that sentence.

I personally don't use bringtofront and sendtoback instead I use visible=True and =False for items I want to see/hide - but that's just my style.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Why aren't you setting the elevation to be larger than 2dip ? 2dip is the buttons elevation so the z order depends on the views order.


Erel,

As I said in the original post, " If I set the panel elevation higher than two the labels on the panel are hidden. ". If I did that I would be swapping one problem for another.

There are several ways to get around this as suggested by johnC and my reply above. It still leaves a mystery, why are some buttons hidden and others not?
I thought I had done something wrong, but if you don't know the answer it's probably unanswerable.
I will look at grouping all views on respective panels. [I see a headache coming on.]

Regards Roger
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
but if you don't know the answer it's probably unanswerable.
Once the elevation is the same, the visibility depends on the views order.
There are many mistakes in the way the layout is built.
1. You should really learn how to use anchors. This will allow you to remove most of the designer script code.
2. Instead of calling BringToFront / SendToBack you should change the elevation as it precedes the views order.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Once the elevation is the same, the visibility depends on the views order.
There are many mistakes in the way the layout is built.
1. You should really learn how to use anchors. This will allow you to remove most of the designer script code.
2. Instead of calling BringToFront / SendToBack you should change the elevation as it precedes the views order.

Erel,
Let's not get in to an argument, but your first sentence Re: the elevation being the same leaves
visibility a function of Z order is what is not happening.
Yes, many errors can be made. Please, in the example what error have I made that causes the program not to behave in the way expected.

Regards Roger

PS
1. Off subject, but I will read up on anchors.
2. I understood that "Panel" was the only view with an Elevation member. I can't recall seeing this method used in the B4A examples.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm sorry but the layout you created is "too messy" for me to debug it.

Set the elevation of all panels in the designer to 0.
Remove all the calls to SendToBack / BringToFront.

When you want to bring a panel to the front:
B4X:
Sub BtnConst_Click
    Pnlview.Elevation = 10dip
    ConstantsRecall
End Sub

There are simpler ways to implement such layout. I would have used B4XDialog here. You can make it fill the screen if you like.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
I'm sorry but the layout you created is "too messy" for me to debug it.

Set the elevation of all panels in the designer to 0.
Remove all the calls to SendToBack / BringToFront.

When you want to bring a panel to the front:
B4X:
Sub BtnConst_Click
    Pnlview.Elevation = 10dip
    ConstantsRecall
End Sub

There are simpler ways to implement such layout. I would have used B4XDialog here. You can make it fill the screen if you like.


Thanks Erel,

Changing the elevation does the trick. The mistake I was making was setting the Elevation in the designer above 2 and leaving it. This is what is advised in many answers to forum questions on this issue. I found nothing suggesting changing the elevation, but we get there in the end.

In searching for an answer/cause I came across a couple of comments that implied that the button shadow/animation can leave a button with an effective elevation of 2+.
There was no clear statement but this is what I inferred. This fits with what I was finding, [the buttons that had been recently operated were the buttons that showed through panel.]

Sorry about the messy code [Circa 2017] but I do so little programming my skills are 2016 beginners level. For example I had to look up B4XDialog.

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
I'm sorry but the layout you created is "too messy" for me to debug it.

Set the elevation of all panels in the designer to 0.
Remove all the calls to SendToBack / BringToFront.

When you want to bring a panel to the front:
B4X:
Sub BtnConst_Click
    Pnlview.Elevation = 10dip
    ConstantsRecall
End Sub

There are simpler ways to implement such layout. I would have used B4XDialog here. You can make it fill the screen if you like.



Erel,

You've convinced me I'm stuck in the 1994-1996 beginners guide. I've downloaded the booklets, pushed the reset button on my B4A knowledge and starting again as if I have never seen B4A. 🙂

Regards Roger
 
Upvote 0
Top