Android Question A question regarding the meaning of %x

Hi, I have a question regarding %x.

What's the correct meaning of %x (or %y)?
A. Specified percentage of the screen's width (or height).
B. Specified percentage of the parent view's width (or height).

Thanks!
 

BlueVision

Active Member
Licensed User
Longtime User
When working with the Designer, the X and Y values generally represent the percentage values of the display dimensions on the end device, your assumption A is correct. This ensures that your views are displayed correctly proportionally on the end device. The problem here is the form factor. A view programmed for a 4:3 display is stretched in width on a 16:9 display. This effect is less severe on a PC (B4J) compared to a modern smartphone (B4A), where form factors of 2:1 are now available.
However, I would advise against using multiple layouts for different form factors. Instead, try to determine the form factor and incorporate it into the calculations of the designerscript.
For the arrangement of control elements in a parent view, the percentage distances are retained, but then refer to the parent view, so they start again at zero if you use Parentviewname.Top or Parentviewname.Left as the basis.
The advantage, however, is that you can also use other options for placement in addition to Top, Bottom, Left and Right, for example Parentview.Horizontalcenter or Parentview.Verticalcenter. Designer scripts have the great advantage that you can specify even more complex calculations in the script, the values do not have to be absolutely fixed, but can also be carried out with variables determined in the script.

It's best to try it out on several devices, you have to develop a little feeling for it and then you will quickly get very useful results.

In any case, using the Designer and its scripting language is the right way to go.

Cheers
 
Upvote 0
Top