'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?
Solution 1:[1]
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.
Solution 2:[2]
Programatically this worked for me (aligning to the right):
spLabel3.getTextAllStyles().setAlignment(Component.RIGHT);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shai Almog |
Solution 2 | Mike Clonts |