giggetto71 Active Member Licensed User Longtime User May 8, 2022 #1 Hi guys, I really apologize for the trivial question but clearly there must be something fundamental I am missing in the layout design. I have attached a sample program. The layout has one panel and the panel has 2 labels. I would like to place label1 for half the width of the panel and label1 same size and left position equal to to the label1. basically each label should take half the size of the screen (the panel has both hor and ver anchors so it actually gets resized to the activity screen). I have tried many combinations but I did not find anything that works. for example if I set both labels with "<->" anchor, I get the below effect. Is there a smart way to do that? actually my real goal is to do the same with two customlistviews because I would like to have them covering each half of the screen..(the tests with the CLV are showing the same results..). any help is really appreciated.. thanks in advance. Attachments Test1.zip Test1.zip 9 KB · Views: 431
Hi guys, I really apologize for the trivial question but clearly there must be something fundamental I am missing in the layout design. I have attached a sample program. The layout has one panel and the panel has 2 labels. I would like to place label1 for half the width of the panel and label1 same size and left position equal to to the label1. basically each label should take half the size of the screen (the panel has both hor and ver anchors so it actually gets resized to the activity screen). I have tried many combinations but I did not find anything that works. for example if I set both labels with "<->" anchor, I get the below effect. Is there a smart way to do that? actually my real goal is to do the same with two customlistviews because I would like to have them covering each half of the screen..(the tests with the CLV are showing the same results..). any help is really appreciated.. thanks in advance.
Sagenut Expert Licensed User Longtime User May 8, 2022 #2 Set Label1 Top and Left anchors. Set label 2 top and right anchors. Upvote 0
giggetto71 Active Member Licensed User Longtime User May 8, 2022 #3 ok thanks. I think I also found a way by using the design script. Upvote 0
toby Well-Known Member Licensed User Longtime User May 8, 2022 #4 You can also use the following designer script: B4X: Copy Label1.SetLeftAndRight(0, 50%x) Label2.SetLeftAndRight(51%x, 100%x) Upvote 0
You can also use the following designer script: B4X: Copy Label1.SetLeftAndRight(0, 50%x) Label2.SetLeftAndRight(51%x, 100%x)
giggetto71 Active Member Licensed User Longtime User May 9, 2022 #5 thank you all guys! sometimes I just forget how powerful is the designer script! Upvote 0
Cableguy Expert Licensed User Longtime User May 9, 2022 #6 toby said: You can also use the following designer script: B4X: Copy Label1.SetLeftAndRight(0, 50%x) Label2.SetLeftAndRight(51%x, 100%x) Click to expand... This line is not correct as on some devices may leave a gap between the labels Label2.SetLeftAndRight(51%x, 100%x) it should be Label2.SetLeftAndRight(50%x + 1dip, 100%x) Upvote 0
toby said: You can also use the following designer script: B4X: Copy Label1.SetLeftAndRight(0, 50%x) Label2.SetLeftAndRight(51%x, 100%x) Click to expand... This line is not correct as on some devices may leave a gap between the labels Label2.SetLeftAndRight(51%x, 100%x) it should be Label2.SetLeftAndRight(50%x + 1dip, 100%x)
LucaMs Expert Licensed User Longtime User May 10, 2022 #7 To "fill" the horizontal space (or the vertical one) "correctly", only one view should have both sides anchored. I mean, in your case, label1 OR label2. This way, however, you would not get the desired. Cableguy said: This line is not correct as on some devices may leave a gap between the labels Label2.SetLeftAndRight(51%x, 100%x) it should be Label2.SetLeftAndRight(50%x + 1dip, 100%x) Click to expand... Both solutions are not perfect, because of the same reason @Cableguy wrotes (in his solution there will be a "gap" of 1dip). Keeping label1 anchored to the Left (it is anchored so by default), set its Left to 0dip, of course. Then: B4X: Copy label1.Width = 50%X label2.SetLeftAndRight(label1.Right, 100%x) Last edited: May 10, 2022 Upvote 1
To "fill" the horizontal space (or the vertical one) "correctly", only one view should have both sides anchored. I mean, in your case, label1 OR label2. This way, however, you would not get the desired. Cableguy said: This line is not correct as on some devices may leave a gap between the labels Label2.SetLeftAndRight(51%x, 100%x) it should be Label2.SetLeftAndRight(50%x + 1dip, 100%x) Click to expand... Both solutions are not perfect, because of the same reason @Cableguy wrotes (in his solution there will be a "gap" of 1dip). Keeping label1 anchored to the Left (it is anchored so by default), set its Left to 0dip, of course. Then: B4X: Copy label1.Width = 50%X label2.SetLeftAndRight(label1.Right, 100%x)
vecino Well-Known Member Licensed User Longtime User May 10, 2022 #8 LucaMs said: To "fill" the horizontal space (or the vertical one) "correctly", only one view should have both sides anchored. I mean, in your case, label1 OR label2. This way, however, you would not get the desired. Click to expand... Where do they explain these things? books? experience? Upvote 0
LucaMs said: To "fill" the horizontal space (or the vertical one) "correctly", only one view should have both sides anchored. I mean, in your case, label1 OR label2. This way, however, you would not get the desired. Click to expand... Where do they explain these things? books? experience?
Cableguy Expert Licensed User Longtime User May 10, 2022 #9 vecino said: Where do they explain these things? books? experience? Click to expand... @klaus has a whole booklet series on b4x where he covers almost every aspect of working with b4x tools. And then comes common sense and logic... after reading the appropriate chapters of the booklets. Last edited: May 10, 2022 Upvote 0
vecino said: Where do they explain these things? books? experience? Click to expand... @klaus has a whole booklet series on b4x where he covers almost every aspect of working with b4x tools. And then comes common sense and logic... after reading the appropriate chapters of the booklets.
LucaMs Expert Licensed User Longtime User May 10, 2022 #11 vecino said: Where do they explain these things? books? experience? Click to expand... Relating to that answer of mine: I read the first part in a few posts (for a long time, years, I read almost all the posts, almost like Erel does). The second part is just a reasoning. Books / manuals. I think they can be useful for a beginner or to be consulted in case of need, but only having searched the Forum before, because it is easier and you can find a number of cases that can be exceptions. I think it's a bit like being a lawyer: I don't think he studies a "criminal (or civil) code book" from the beginning, but he consults it when needed. The site, the forum, is a bit like consulting an archive of concluded lawsuits. Upvote 0
vecino said: Where do they explain these things? books? experience? Click to expand... Relating to that answer of mine: I read the first part in a few posts (for a long time, years, I read almost all the posts, almost like Erel does). The second part is just a reasoning. Books / manuals. I think they can be useful for a beginner or to be consulted in case of need, but only having searched the Forum before, because it is easier and you can find a number of cases that can be exceptions. I think it's a bit like being a lawyer: I don't think he studies a "criminal (or civil) code book" from the beginning, but he consults it when needed. The site, the forum, is a bit like consulting an archive of concluded lawsuits.