B4J Question B4j Designer script problems

Schakalaka

Active Member
Licensed User
Longtime User
Hello,
I have create a customlistview in b4j.

1742231718110.png


i want use the "script" and define the size of each element, but the result is not as expected:
all elements have .top = 10%y but this is the result

1742231742799.png


B4X:
lblEAN.Top = 10%y
lblEAN.Left = 4%x
lblEAN.Width = 6%x
lblEAN.Height = 8%y

edtEan.Top = 10%y
edtEan.Left = lblEAN.Right + 2%x
edtEan.Width = 14%x
edtEan.Height = 6%y

lblDeviceName.Top = 10%y
lblDeviceName.Left = edtEan.Right + 2%x
lblDeviceName.Width = 12%x
lblDeviceName.Height = 8%y

edtDeviceName.Top = 10%y
edtDeviceName.Left = lblDeviceName.Right + 2%x
edtDeviceName.Width = 16%x
edtDeviceName.Height = 6%y

Where is the problem?
Thank you
 

BlueVision

Well-Known Member
Licensed User
Longtime User
Have you tried to "bias" the labels in the row and to make them a little bit larger?
B4X:
lblEAN.SetTopAndBottom(10%y,20%y)
lblEAN.LeftAndRight(4%x,10%x)
After that, try to adjust the remaining labels to the EAN-label:
B4X:
lbldevicename.Top = lblEAN.Top
lbldevicename.Bottom = lblEAN.Bottom
Try to level all labels in a row, looks better. You are using different height's.

You don't have to define all the labels in all dimensions. Advantage: It is somehow selfscaling...
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
The problem is the intrinsic difference between a Label and an EditBox... Even if placed with the exact same layout dimension, they will not have the same representation dimensions on screen.
MoreOver, the EditBox has settings like padding and Font size that overrule and affect the visual representation of the view.
 
Upvote 0

BlueVision

Well-Known Member
Licensed User
Longtime User
intrinsic difference between a Label and an EditBox
Indeed, but it is posible to "level out" this by using non-integer-percentages (10.2%, 10,3%). Had this phenomenon with a B4X-switch too, when remembering correctly...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Try using DDD, and set both Padding and Margin values to 0 (may require css), but even then, some letters my appear cut-off
 
Upvote 0

Schakalaka

Active Member
Licensed User
Longtime User
1742330597190.png


the editboxes are B4XFloatTextField
I have find the sizes:

B4X:
lblEAN.Top = 10%y
lblEAN.left = 4%x
lblEAN.Width = 6%x
lblEAN.Height = 18%y

edtEan.Top = 10%y
edtEan.Left = lblEAN.Right + 2%x
edtEan.Width = 14%x
edtEan.Height = 10%y

lblDeviceName.Top = 10%y
lblDeviceName.Left = edtEan.Right + 2%x
lblDeviceName.Width = 12%x
lblDeviceName.Height = 18%y
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
I find that rather than aligning View.Top=...... that aligning View.VerticalCentre presents a visually better result when aligning dissimilar views. You can then play with the View.Height to finesse the presentation.

KISS principle!
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I find that rather than aligning View.Top=...... that aligning View.VerticalCentre presents a visually better result when aligning dissimilar views
If the views are all at top 10%y but have different heights, they will necessarily not be vertically aligned.
In the script, set [YourView].VerticalCenter = 15%y (or similar).
 
Upvote 0
Top