Justified alignment on text imported from a text document

cammel8

Member
Licensed User
I think I am posting this in the correct place, but if not, I am sorry, and please could someone move this to the correct area.

OK here is my problem. I am making a rulebook for a pool league I am on. I am pulling the rules out of a text document and displaying them on a scrollview label, named label3. So far everything is working good. My problem comes in with formatting.

The way I have it now is label1 has heading , label2 page number and label3 main text. Like so:

AGE REQUIREMENTS
19
You must be at least 18 years of age to participate. Some League areas may be restricted to 21 years of age as State, Province and Local Laws require. Check your Local League bylaws for age requirements in your APA area. Teams playing underage players may face penalties. Exception: Junior Leagues, if available, have no minimum age restriction except where local ordinances apply.

As you can see the above is aligned to the left. I want it aligned to fill the whole area as if it was aligned both left and right.

I have tried gravity.fill thinking that might do it but it does not seem to do anything at all to change it.

Is there a way to have justified alignment without doing it in the text document itself. For one the text document is wider than the screen on the phone so I would have to format the text differently in each and second I have over 150 text documents. I really don't want to have to edit 150 text docs.

Any help I could get would be greatly appreciated.


Thank You
George
 

stevel05

Expert
Licensed User
Have you looked at webview and HTML? You could probably set up one region and format the whole document.

I'm afraid I don't know HTML very well, but it seems likely that it'll do what you want. I'm sure someone else could point you in the right direction, or google.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
19 views and no posts. does this mean i am barking up the wrong tree? Is it not possible to do?

Personally, I wasn't sure what you meant by:

You must be at least 18 years of age to participate. Some League areas may be restricted to 21 years of age as State, Province and Local Laws require. Check your Local League bylaws for age requirements in your APA area. Teams playing underage players may face penalties. Exception: Junior Leagues, if available, have no minimum age restriction except where local ordinances apply.

As you can see the above is aligned to the left. I want it aligned to fill the whole area as if it was aligned both left and right.

Did you mean that you want to set a right margin on the above text? Or do you mean that you want microjustification where spaces between letters are increased to cause the text on each line to go all the way to the right edge?
 
Upvote 0

cammel8

Member
Licensed User
Or do you mean that you want microjustification where spaces between letters are increased to cause the text on each line to go all the way to the right edge?

Yeah that. like when you read a magazine the columns of text look like it is both right and left justified and the spaces in the middle are increased to make up the difference.
B4X:
instead of :
hello how are you 
i'm fine thanks
hello how are you 
i'm fine thanks

you have:
hello how are you
I'm  fine  thanks
hello how are you
I'm  fine  thanks
Notice the side looks nice and smooth on both the left and right side of the text. That's the result I am looking for.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Yeah that. like when you read a magazine the columns of text look like it is both right and left justified and the spaces in the middle are increased to make up the difference.
B4X:
instead of :
hello how are you 
i'm fine thanks
hello how are you 
i'm fine thanks
 
you have:
hello how are you
I'm  fine  thanks
hello how are you
I'm  fine  thanks
Notice the side looks nice and smooth on both the left and right side of the text. That's the result I am looking for.

Nice and smooth with big gaps between words. :) That's not microjustification, which spreads, say, 40 pixels of space by putting two pixels between each of 20 characters on a line versus the above which is putting two 20-pixel gaps between words.

Anyway, I don't think there is any automatic way to do either one in B4A, but it shouldn't be that hard to kludge either method.

It's may be possible to use LEFT AND RIGHT in Canvas1.DrawText to do what you want, but I don't know. Erel has mentioned ANDing similar things but I've never tried them.
 
Upvote 0

warwound

Expert
Licensed User
Hi.

Take a look at this HTML/CSS feature:

CSS3 text-justify

That webpage says it's supported ONLY in Internet Explorer BUT i just loaded the example page in a B4A WebView and the text was properly justified.

A WebView will give you much more flexibility when it comes to displaying nicely formatted text i think.

Martin.
 
Upvote 0
Top