Designer Script Problem!

salmander

Active Member
Licensed User
Longtime User
Hi All,

I have a panel as panel1. In the panel i have button1 and button2.
But this code doesn't seem to work for me in Designer Script
B4X:
Panel1.SetLeftAndRight(0, 100%x)
Panel1.Bottom = 89%y
Button1.Top = Panel1.Top
Button2.Bottom = Panel1.Bottom

The buttons disappear from the Panel. Anyone knows what I am doing wrong here?
 

salmander

Active Member
Licensed User
Longtime User
Thanks for your reply NJDude. It doesn't seems to work either. The button2, is only half way on panel1. And secondly, I don't wish to resize my panel. I just want to set the panel1.bottom should be at the 89% of the Activity, which is working fine. But the views inside doesn't gets re-aligned in relation to the panel. The button1 should appear at the top of the panel and button2 should appear at the bottom of the panel. Is this a bug?
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
hmmm strange! It's sad. I only started using designer scripts and found this behaviour Lets see what Erel has to say about this. Hope to find a viable solution soon.

peace NJDude
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The buttons disappear from the Panel. Anyone knows what I am doing wrong here?
Yes. The button coordinates are relative to the panel (its parent).
You should change your code to:
B4X:
Button1.Top = 0
Button2.Bottom = Panel1.Height
Note that this code is logically wrong as you are first setting the Top property and then the Bottom property. The button's height will not change.

If you want the button to fill the panel then you should use:
B4X:
Button1.SetTopAndButtom(0, Panel1.Height)
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
I understand the Button1.top = 0
But, why isn't button2.bottom = panel1.bottom right? As I am setting the bottom property of button2 to whatever it is of panel1. For e.g: If panel1.bottom = 300 then button2.bottom will be equal to 300. Therefore, the button2 should appear right at the end of the panel (without changing the height of the button).
Note that this code is logically wrong as you are first setting the Top property and then the Bottom property.
Why is it logically wrong? I am setting the bottom and top properties of two different buttons here.
The button's height will not change.
I am not trying to change the height of the button. I am changing to position of the buttons relative to the panels position.
If you want the button to fill the panel then you should use:
B4X:
Button1.SetTopAndButtom(0, Panel1.Height)

cheers Erel
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Why is it logically wrong?
Oops. Didn't see that these are two different buttons.

But, why isn't button2.bottom = panel1.bottom right?
Lets say that Panel1.Top = 200 and Panel1.Bottom = 500 (Panel1.Height = 300).
When you set Button2.Bottom = Panel1.Bottom you are setting Button2.Bottom = 500
However Button2 is a child of Panel1. So 500 is relative to Panel1. As Panel1 height is only 300, Button2 will be hidden.

If you think of it, this is exactly the same reason that Button1.Top = 0 is correct.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…