2 pixel displacement

specci48

Well-Known Member
Licensed User
Hi,

I am wondering about this strange behaviour:

I have created a Form1 and added a Label1 with the designer. Label1 has the following properties:
top = 50
left = 100
width = 50
height = 20

After that, I added this code:
B4X:
Sub Globals
End Sub

Sub App_Start
   Form1.Show
   AddLabel("Form1","Label2",50,Label1.Top,Label1.Width,Label1.Height,"Label2")
   AddLabel("Form1","Label3",150,Label1.Top + 2,Label1.Width,Label1.Height,"Label3")
End Sub
If I start this code on the desktop, I can see (as shown in the attachment):
- Label1 is the reference
- Label2 is displaced (2 pixels HIGHER than Label1) :confused:
- Label3 has the same top position as Label1 :confused:

If I start that code on the device I'll get the (estimated) result:
- Label1 is the reference
- Label2 has the same top position as Label1
- Label3 is displaced (2 pixels LOWER than Label1)

So why does this happen on the desktop?


specci48
 

agraham

Expert
Licensed User
Interesting!

If you set the background colours different to that of the form you can see that the labels are all in the correct position, it is the position of the text within the added labels that is different.

A further peculiarity, on my system at least, is the the label added at design time with the default background colour has the same colour background as the form, whereas those added at runtime have a different, slightly darker background colour.
 
Last edited:
Top