Android Question CSBuilder and SpaceBetweenLines

bsnqt

Active Member
Licensed User
Longtime User
Dear Erel and All

CSBuilder is really strong and useful tool, I use it a lot in all my apps. However there are somethings I am still unclear and need to learn more.
I tried to search the forum but could not find relevant information.
I need to change the space between 2 lines (with different sizes), in the attached picture it is shown as space "a", as well as in within the same line (space "b")

How can I do it?

(Sometimes I use a workaround but it is too complicated and result cannot be predictable, for example insert one more line (CRLF) in between the lines etc.)

Thank you.

csbuilder.png
 
Solution
But I still cannot understand the property RelativeSize(2) and why you did use it (in my project I use cs.size(xy) for every single line if they are different in size). Does RelativeSize affect the space between lines?
The relative size is the size with respect to the previous one. If the previous text has size(20), and the next text set with relativesize(1.5), it will be 1.5 times bigger. The vertical alignment accounts for the space shifting. Best to experiment with different sizes to see the effect.
B4X:
'IMAGE ONE
cs.Initialize.Size(22).color(xui.Color_Red).VerticalAlign(-10dip).Append("This is a first line").pop.pop.relativesize(1.5).append(CRLF).VerticalAlign(-10dip).Append("This is a second line"). _...

Mahares

Expert
Licensed User
Longtime User
Did you try VerticalAlign(-10dip)
B4X:
Dim cs As CSBuilder
cs.Initialize.RelativeSize(2).color(xui.Color_Red).VerticalAlign(-10dip).Append("This is a first sentence").pop.pop.append(CRLF).Append("This is a seconline"). _
    Append(CRLF).Append("This is third line").PopAll
    Label1.Text =cs
 

Attachments

  • csbuilder112221.png
    csbuilder112221.png
    22.9 KB · Views: 136
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Thank you Mahares,

Yes I did try the VerticalAlign, as well as CRLF "trick" :) . The only unclear thing for me is that the result cannot be predictable (at least for me). If I use the VerticalAlign, I need to debug and see how the final text looks like, then "manually" adjust font size and value of VerticalAlign (go up or down 10dip, -10dip, -8dip) etc... When you have more than 3 lines with different font sizes, it is more complicated. If there is no more workaround, I will continue using VerticalAlign to understand it more and master it.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Perhaps when it comes to Csbuilder a powerhouse like Erel or some other member can help with a more plausible solution. You should have mentioned in your first post that you tried VerticalAlign. This way, I would not have wasted your time by giving you an inadequate answer. I don't know if BBLabel or BBCodeView can do it also. I have not gone that far with them.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Perhaps when it comes to Csbuilder a powerhouse like Erel or some other member can help with a more plausible solution. You should have mentioned in your first post that you tried VerticalAlign. This way, I would not have wasted your time by giving you an inadequate answer. I don't know if BBLabel or BBCodeView can do it also. I have not gone that far with them.

Actually, your post is very adequate as it helps me (and others) in confirming that I am not alone in doing right thing with VerticalAlign. I did replicate your code in my app to see if any difference, it seems I am doing same as yours. But I still cannot understand the property RelativeSize(2) and why you did use it (in my project I use cs.size(xy) for every single line if they are different in size). Does RelativeSize affect the space between lines? There are still a lot of things I need to learn.

Edit. The only link I found about csBuilder and spacebetweenline is the following: https://www.b4x.com/android/forum/t...ilder-and-correct-label-height.85430/#content, but it does not really come to a clear solution.
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I find it interesting to share:

 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
But I still cannot understand the property RelativeSize(2) and why you did use it (in my project I use cs.size(xy) for every single line if they are different in size). Does RelativeSize affect the space between lines?
The relative size is the size with respect to the previous one. If the previous text has size(20), and the next text set with relativesize(1.5), it will be 1.5 times bigger. The vertical alignment accounts for the space shifting. Best to experiment with different sizes to see the effect.
B4X:
'IMAGE ONE
cs.Initialize.Size(22).color(xui.Color_Red).VerticalAlign(-10dip).Append("This is a first line").pop.pop.relativesize(1.5).append(CRLF).VerticalAlign(-10dip).Append("This is a second line"). _
    Append(CRLF).pop.RelativeSize(.5).Append("This is a third line").PopAll
    Label1.Text =cs
    Label2.Text =cs

B4X:
'IMAGE TWO
Dim cs As CSBuilder
    cs.Initialize.Size(22).color(xui.Color_Red).VerticalAlign(-10dip).Append("This is a first line").pop.pop.relativesize(1.5).append(CRLF).VerticalAlign(-10dip).Append("This is a second line"). _
    Append(CRLF).pop.RelativeSize(.5).Append("This is a third line").PopAll
    Label1.Text =cs
    
    cs.Initialize.Size(22).color(xui.Color_Red).VerticalAlign(0dip).Append("This is a first line").pop.pop.relativesize(1.5).append(CRLF).VerticalAlign(0dip).Append("This is a second line"). _
    Append(CRLF).pop.RelativeSize(.5).Append("This is a third line").PopAll
    Label2.Text =cs
 

Attachments

  • one.png
    one.png
    24.2 KB · Views: 129
  • two.png
    two.png
    24 KB · Views: 116
Upvote 0
Solution

bsnqt

Active Member
Licensed User
Longtime User
Hi Mahares

With your examples now I understand more about the VerticalAlign, it cannot be clearer. I used it before but did not really understand it. Although here we don't have any property like "line-height" (or similar), with VerticalAlign somehow we can do it. I will pay more time to experiment with different sizes to see how I can manage it. Thank you so much for your time and help.

Hi oparra,

Thanks for your help, I did go to the links you sent, they give me more information and understanding about characters, lines and so on (though I could only open the second link, maybe the first link requires an account information)

Have a nice day :)
 
Last edited:
Upvote 0
Top