Android Question Centering text in label programmatically

Scotter

Active Member
Licensed User
Hi -

In the designer I've set the padding, horiz align to "center_horizontal", and vert align to "center_vertical".
And in my activity_create:
B4X:
    '......................padding: left, top, right, bottom

    lblCard1.Padding = Array As Int(10dip,10dip,10dip,10dip)
    lblCard1.Gravity=Gravity.CENTER_HORIZONTAL
    lblCard1.Gravity=Gravity.CENTER_VERTICAL
    lblCard1.TextSize=34
But I get left justified when I run the program.
Ideas?
 

mangojack

Well-Known Member
Licensed User
If you are setting these properties in Designer ... there is no need to call them again in code.

Removing the lines from Activity_Create solves the problem .. although I can't explain why the problem is created by these lines.

Maybe someone can explain / expand on this later.
 
Upvote 0

Scotter

Active Member
Licensed User
If you are setting these properties in Designer ... there is no need to call them again in code.

Removing the lines from Activity_Create solves the problem .. although I can't explain why the problem is created by these lines.

Maybe someone can explain / expand on this later.

OMG that worked!
 
Upvote 0
Top