Bug? Designer %x and %y

LucaMs

Expert
Licensed User
Longtime User
It seems to me that there is a bug in the designer (B4A 3:00)

As an example:

I have a panel containing a checkbox.

When I use:
Checkbox.Left = 10%x the Designer implies that the 10% refers to the panel;

If I use a calculation:
Checkbox.Left = (100%x - Checkbox.Width) / 2, the designer uses 100% of the screen
 

klaus

Expert
Licensed User
Longtime User
In the Designer Scripts %x and %y refer to the dimensions of the parent view of the layout, not any parent view in the layout !
If you load a layout onto the Activity, 100%x = Activity.Width and 100%y = Activity.Height !
If you load a layout onto Panel2, 100%x = Panel2.Width and 100%y = Panel2.Height !
The attached small program shows it !
For of all three buttons Left = 10%
Button3 is on a seperate layout file loaded onto the red panel.
 

Attachments

  • TestLayoutXY.jpg
    TestLayoutXY.jpg
    18.9 KB · Views: 183
  • TestLayoutXY.zip
    8 KB · Views: 182

klaus

Expert
Licensed User
Longtime User
Did you read my post#2 and look at the attached project ?
You don't say where you load the layout file.
So, I suppose that you load onto the Activity, therefor 100%x is the width of the Activity, 320pixels in your case.
CheckBox1.Left = 20%x = 0.2 * 320 = 64pixels !
CheckBox2.Left = 100%x - 240dip = 320 - 240 = 80 pixels.
That's what I explained in post #2 !
 

LucaMs

Expert
Licensed User
Longtime User
Thus, the percentage refers to the container but only at RUNTIME!

In fact, in your calculation in #4 you use 100% of the screen even though the view is part of a panel!

This has generated confusion (not only to me!)

It is clear, now.

Thanks again, Klaus (especially for your patience :))
 
Top