label alignment doesn't appear to work correctly.

5 replies [Last post]
slgilley
User offline. Last seen 17 weeks 19 hours ago. Offline
Joined: 19 Feb 2010

I have ten labels in a column, all with the exact same bounds except for the y attribute. All have "align" set to left. However, different text shows up with a different left position. I thought I had read there was a potential problem on the simulator, but this occurs on an actual iPhone as well.

Same problem for align = "right".

Also, same problem if I use label.align = "left", though I honestly wouldn't expect that to change things.

Am I missing something?

Sean.

Replies

Matthew Pringle
User offline. Last seen 3 weeks 3 days ago. Offline
Joined: 23 Feb 2010

Im too having issues. If I attach a ui label to a group and rotate that group the text alignment shifts while the group is being rotated. Im assuming this is a current bug and will hopefully be fixed shortly (or no landscape mode my my app!)

carlos m. icaza's picture
carlos m. icaza
User offline. Last seen 3 hours 44 min ago. Offline
Ansca Staff
Joined: 22 Jun 2009

could you guys provide me with some code to look at

info@anscamobile.com

c

slgilley
User offline. Last seen 17 weeks 19 hours ago. Offline
Joined: 19 Feb 2010

Not a whole lot I can show you, but here's some code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- This implements my high score list.
local label_hchaln1 = ui.newLabel{
        bounds = { 33, 50, 125, 20 },
        text = "Sean",
        textColor = { 255, 255, 255, 255 },
        size = 16,
        align = "left"
}
label_hchaln1.isVisible = false
-- much later in code, and after an event..
                showHighScoresGroup:insert(label_hchals1)
                label_hchaln1.isVisible = true
                if(scores_hchal[1] > 0) then
                        label_hchaln1.text = names_hchal[1]
                else
                        label_hchaln1.text = " "
                end
-- and even though I know it shouldn't be necessary, and it doesn't seem to help
-- I do:
                label_hchaln1.align = "left"
                showHighScoresGroup.parent:insert(showHighScoresGroup)

When the above code (plus mode, of course) finishes, the user should see a two column high score list, the names left justified, the scores right justified. What I see, however, is not left (or right) justified. The label contents are centered within the entire label width.

Aligning left, center, or right does make a different, but the labels aren't pushed all the way left or right when aligned accordingly.

If you want to shoot me an email, I can provide you a screen shot of what it looks like.

Sean.

carlos m. icaza's picture
carlos m. icaza
User offline. Last seen 3 hours 44 min ago. Offline
Ansca Staff
Joined: 22 Jun 2009

email me a screenshot as well.

support@anscamobile.com

carlos

evank
User offline. Last seen 1 year 4 weeks ago. Offline
Joined: 16 Sep 2009

This bug comes up in a couple of other threads, but I'm logging it here as bug #127.

The solution is the same in all cases: the ui.label object is a fairly lightweight convenience function that was basically designed to right-align fields in the Compass sample app. People are now using it for more robust purposes, and this needs to be rebuilt at a lower (non-Lua) level so it behaves as expected.

Also, we've roadmapped native landscape support, which will simplify landscape coding in general.

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.