Span Label line break issue

180 views
Skip to first unread message

helio...@gmail.com

unread,
Aug 27, 2015, 4:13:10 AM8/27/15
to CodenameOne Discussions
Hi,

I'm having this problem.
The span label breaks the line too soon, when is still enough space for some words.
In the simulator it seems ok, but when I compile and install on device, it shows like this:


This is an Android app, and the device is an HTC Desire 500.
I'm using only the codename one designer to construct the label.
The theme already have all paddings and margins to 0, to force the span label occupy the entire width of the screen.
I also have tried to construct the span label through code, but get the same problem.

Can you help?

Fabrizio Grassi

unread,
Aug 27, 2015, 7:06:28 AM8/27/15
to CodenameOne Discussions
Hi,
You should provide more informations about the form's structure.
Also, it seems to me that the two words that go on a new line are too long to behave differently...

helio...@gmail.com

unread,
Aug 27, 2015, 9:58:10 AM8/27/15
to CodenameOne Discussions
What kind of information is needed about the form?
Its a regular form with BorderLayout.
The span label is on a container in center of BorderLayout of form.

I think the word "alertado" is short enough to belongs to the first line.

Fabrizio Grassi

unread,
Aug 27, 2015, 7:29:35 PM8/27/15
to CodenameOne Discussions
Try giving the SpanLabel a green line border theme to see if it really occupy the whole space but breaks the lines too soon or if it doesn't occupy the whole space.
The order is:
contentPane()
|_container(borderLayout)
| |_SpanLabel:center
| |_plus:east
Etc?

helio...@gmail.com

unread,
Aug 28, 2015, 4:21:33 AM8/28/15
to CodenameOne Discussions
Hi,

Thank you, for your help.

I create a new project from scratch, just do demonstrate this issue.
It's just a form with layout "BoxLayout Y".
Inside have a SpanLabel.
This SpanLabel use as UIID the component "Container", which have the default settings.
Also use as textUiid the conponent "Label", which I've changed the font size, padding and margins all to 0, and add a red border.
Once again, in the simulator is fine, but on device looks like this:


If it helps, I've compressed the whole project in here:

Thank you,

Chen Fishbein

unread,
Aug 28, 2015, 5:05:51 AM8/28/15
to CodenameOne Discussions, helio...@gmail.com
Hi,
It is very much likely you hit a known issue with the TextArea which do the line breaking inside your SpanLabel.
It is very difficult to determine where to break lines, I won't get into the details... but usually another revalidate on your Form before you display it will workaround this issue.


helio...@gmail.com

unread,
Aug 28, 2015, 5:53:00 AM8/28/15
to CodenameOne Discussions, helio...@gmail.com
Hi Chen,

I did this:

@Override
protected void beforeMain(Form f) {
   f
.revalidate();
}

No luck.
Same issue here.

Chen Fishbein

unread,
Aug 28, 2015, 6:24:40 AM8/28/15
to CodenameOne Discussions, helio...@gmail.com
Hi,
I downloaded your project and after adding the revalidate it worked fine
 
 

helio...@gmail.com

unread,
Aug 28, 2015, 7:31:51 AM8/28/15
to CodenameOne Discussions, helio...@gmail.com
Hi Chen,

Did you tried on a device, or in simulator?

I still having the problem even with the revalidate.
This time I tested on another device, Wiko Lenny.
This is how it looks:




Chen Fishbein

unread,
Aug 28, 2015, 8:17:20 AM8/28/15
to CodenameOne Discussions, helio...@gmail.com
Hi,
Tried on both.

Can you try:

1) a couple of revalidates: 
 
f.revalidate();
f.revalidate(); 

2)Can you try to use a TextArea uneditable with the same text?





helio...@gmail.com

unread,
Aug 28, 2015, 12:56:36 PM8/28/15
to CodenameOne Discussions, helio...@gmail.com
Hi Chen,

Almost done.

Replacing the SpanLabel with a TextArea, seems to be a solution.
However if I use a diferent component as UIID, the problem returns.
Check this out:
First box is the original SpanLabel, with the line break issue.
Second box is the TextArea with defaul UIID named "TextArea". It's fine!
Third Box, is another TextArea but with a new UIID called "TextArea2". Line break issue again.

This new UIID, is component theme derived from the original "TextArea", but with font in bold style.
What I'm doing wrong?

Onde again, here is the updated project:

Thank you


Shai Almog

unread,
Aug 29, 2015, 1:22:44 AM8/29/15
to CodenameOne Discussions, helio...@gmail.com
Hi,
give a large value to the columns in the text area. This issue sometimes happens in edge cases where recursive reflow is needed.

helio...@gmail.com

unread,
Sep 2, 2015, 4:44:55 AM9/2/15
to CodenameOne Discussions, helio...@gmail.com
Hi Shai,

I've changed the columns from 3 (default) to 100. Same issue.
Then changed to 200 columns but same issue occurs.

I remind that this is happening only in the third text area that is using a custom UIID derived from the original "TextArea".
If I use the original UIID, the line breaks perfectly.

Thanks.

Shai Almog

unread,
Sep 2, 2015, 11:15:33 PM9/2/15
to CodenameOne Discussions, helio...@gmail.com
Hi,
try to explicitly define the padding/margin and border properties of the UIID and do them for both unselected/selected. Its possible that line breaks because of differences between the selected/unselected states.

helio...@gmail.com

unread,
Sep 3, 2015, 6:54:08 AM9/3/15
to CodenameOne Discussions, helio...@gmail.com
Hi Shai,

You have done it! Thanks a lot!

Explicitly defining of padding, margin and border of the new UIID both for unselected/select resolve the issue.
Here is how it looks now:



Thank you!


Reply all
Reply to author
Forward
0 new messages