netsuite_insights
netsuite_insights

Reputation: 462

How can I center a SpanLabel's text in CodenameOne?

Contrary to what is shown in the sample usage section of the SpanLabel documentation, where the text is centered by default, the text of my SpanLabel is left-aligned (see screenshot from simulator below). How can I center it?

enter image description here.

Upvotes: 2

Views: 353

Answers (2)

Mike Clonts
Mike Clonts

Reputation: 91

Programatically this worked for me (aligning to the right):

spLabel3.getTextAllStyles().setAlignment(Component.RIGHT);

Upvotes: 1

Shai Almog
Shai Almog

Reputation: 52760

SpanLabel has a setTextUIID method that allows you to determine the UIID of the text within. This defaults to Label for ease of use but you can change that to anything you want and define that to be centered.

Upvotes: 3

Related Questions