Open ciscorucinski opened 9 years ago
Screenshots?
John Hammond text.
1st - PLAIN_TEXT : (period, not stretched) 2nd - FORMATTED_TEXT : (no period, stretched)
The correct way to perform justification is the 1st way you mentioned. The 2nd way seems to be a bug (although the tests I have written seem to show otherwise). Can you provide some code?
Yes, I only noticed this when I was testing the issue on my last question. Without that, I would never have found this bug.
ViewHolder: https://gist.github.com/ciscorucinski/02b8ba7ca519cd894ed7
This code works; however change PLAIN_TEXT to FORMATTED_TEXT to see the issue.
I updated the gist because it was out-of-date from this issue I was having. Now it matches my code.
I have reduced this down to the combination of FORMATTED_TEXT and TextAlignment.JUSTIFIED.
Something with that will remove the period which causes the last-line-alignment issue
@ciscorucinski Try to set justification via. JustifySpan.
Example: https://github.com/bluejamesbond/TextJustify-Android/blob/master/sample/src/main/java/com/bluejamesbond/text/sample/test/ChineseCharacterTest.java#L66
And let me know if that produces the same issue.
hmmm, that is a lot of extra and more complex code. Is that the simpliest way to add JustifiedSpan???
This issue is not how I am implementing my code, I just found it on accident when I forgot to change back to PLAIN_TEXT.
You can add JustifiedSpan as you would any Android span. I was just showing you an example where I used JustifiedSpan.
I never programmed with Spans before.
But to go back, using TextAlignment.JUSTIFIED with FORMATTED_TEXT works. it justifies the text, all that you have to do is figure out why the period was removed. Off-by-one error? something else?
I will mark this issue as a bug. I don't think I have time to fix it at the moment; possibly in the coming weeks. Thanks for catching it!
I understand the concept of Spans, just never programmed with them yet. Yeah, I understand that the FORMATTED_TEXT would allow you to justify a subset of the block, but it seems like this would be the defacto way of justifying the whole FORMATTED_TEXT block. I assume this would not stop you from add specific spans in addition.
Take your time. I am implementing my solution with PLAIN_TEXT anyway.
There is an issue with Justified text that is set with FORMATTED_TEXT.
With Justification, if the last line ends with a period, then it will not be stretched out to fill the line. This period is removed with FORMATTED_TEXT.
If you change nothing but FORMATTED_TEXT to be PLAIN_TEXT then the justification works perfectly. So the issue is dealing with FORMATTED_TEXT