layout: text alignment not working? #3596
Replies: 7 comments 2 replies
-
Posted at 2021-12-29 by Andreas_Rozek The attached screenshot illustrates what I expected - but I reached that state with a custom renderer only:
Here is a simple "smoke test" for the above "component":
(the "Label" component is part of my Bangle.js 2 activities as documented on GitHub)Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-29 by Andreas_Rozek I've just added a
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by @gfwilliams The issue is you don't have Without it the element is sized to fit the text exactly, so then aligning within that box has no effect. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by Andreas_Rozek No, all cells have a fixed width and height (namely 1/3 of the full screen width/height) and texts should have been aligned within these cells... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by @gfwilliams Ok, just checked and the issue is documentation - but maybe the label renderer should be smarter too. halign/valign do align the element within its container. As a result, But if you specify a size for the element that fills the container there is no room for alignment, so there is no effect. Once you have the element size set, the label is just rendered in the middle of that element, regardless of alignment requested |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-01-05 by Andreas_Rozek I see. On the other hand, I usually preset the (minimum) size of a control (e.g., in order to keep them equal across rows/columns) and then want the text to be properly aligned within its cell. Thats what my "Label" control (and all the others) do. Thus, don't worry right now (perhaps update docs, at least) - I already have a "workaround" |
Beta Was this translation helpful? Give feedback.
-
I came across this post because I too thought text alignment was broken, and since the very helpful page about using Layouts doesn't have an alignment example I thought I'd post one here. The key point to realize is that when something fills its entire space (i.e., with fillx:1) it will always be centered and the alignment will have no effect.
Set fillx to 1 above and you'll see that the halign value has no effect because the text box fills the entire width and the text is centered within the box. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-29 by Andreas_Rozek
Is there any possibility to align some text within its cell when using the layout library?
halign
andvalign
don't seem to be respected as you can see yourself by running the following example:Attachments:
Beta Was this translation helpful? Give feedback.
All reactions