B4J Question [SOLVED] Decrease the line Spacing with a TextFlow?

stevel05

Expert
Licensed User
Longtime User
Try
B4X:
TextFlow.As(JavaObject).RunMethod("setLineSpacing",Array(-2.0))

If you are using Erel's Class, you will have to do it on the returned object after you've called CreateTextFlow.

B4X:
    Dim pane As Pane = tf.CreateTextFlow
    MainForm.RootPane.AddNode(pane, 10, 10, 200, 100)
  
    pane.As(JavaObject).RunMethod("setLineSpacing",Array(-2.0))
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
In Java I guess it is possible to decrease line spacing
Java:
textFlow.setLineSpacing(-2.0);
Is it Possible in B4J?

Thanks for any help.
You can add more methods to the class.
Example:
B4X:
Public Sub SetLineSpacing(Spacing As Double) As TextFlow
    lastItem.RunMethod("setLineSpacing", Array(Spacing))
    Return Me
End Sub
Note:
It was also added to the library XUI Views (B4JTextFlow)
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Try
B4X:
TextFlow.As(JavaObject).RunMethod("setLineSpacing",Array(-2.0))

If you are using Erel's Class, you will have to do it after you've called CreateTextFlow on the returned object.

B4X:
    Dim pane As Pane = tf.CreateTextFlow
    MainForm.RootPane.AddNode(pane, 10, 10, 200, 100)
  
    pane.As(JavaObject).RunMethod("setLineSpacing",Array(-2.0))
Worked like a charm in terms of reducing the space between the text, Unfortunately, the purpose of this exercise is to reduce the height of the pane and as near as I can tell the pane created cannot be resized. Changing prefheight seems to have no effect even after adding it to my listview.
prefheight always shows as -1.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The pane does resize when the line spacing changes. How that corresponds to it's size in a list view is another matter.

With just two or three lines you wouldn't see much of a reduction.

1.gif


I don't think it's possible to change the size of a Textflow directly as it resizes to fit it's content.

Probably the best way would be to reduce the font size.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
The pane does resize when the line spacing changes. How that corresponds to it's size in a list view is another matter.

With just two or three lines you wouldn't see much of a reduction.

View attachment 135441

I don't think it's possible to change the size of a Textflow directly as it resizes to fit it's content.

Probably the best way would be to reduce the font size.
With what I am doing it probably doesn't resize enough to see the bottom of the pane. Thanks for your help. I will fiddle some more.
 
Upvote 0
Top