support text wrapping and centering - #146
Conversation
Prevent long texts to be covered by the slide icon button as well as gets cut off by supporting text-wrapping.
cortinico
left a comment
There was a problem hiding this comment.
Thanks for you change @JeppeLeth and sorry for the late review but I was taking some time for Xmas 馃巺
Overall the change looks good, but there are a couple of things to address:
-
With this change the text is now not centered anymore. This is a pretty significant behavioural change that I'd rather avoid. I believe we should apply the canvas translation only if the number of lines is above 1.

-
I believe we should increase the left margin as the text is bleeding below the slider.

-
The text is having a funny yet weird animation when resetting the slides. This goes along the way that the
StaticLayout.Builder.build()method should be invoked only once and not on everyonDraw:

-
Examples should be added, ideally here: https://github.com/cortinico/slidetoact/blob/master/example/src/main/res/layout/content_text_size.xml
| val leftOffset = | ||
| (mAreaHeight - 2 * mActualAreaMargin).toFloat() / mAreaHeight.toFloat() * | ||
| mBorderRadius.toFloat() * 2 |
There was a problem hiding this comment.
Can you move this inside the else branch?
| val mTextTop = 0 + dY | ||
| val mTextRight = mAreaWidth - mActualAreaWidth - dX | ||
|
|
||
| canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat()) |
There was a problem hiding this comment.
| canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat()) | |
| canvas.translate(mTextLeft, mTextTop.toFloat()) |
| val mTextRight = mAreaWidth - mActualAreaWidth - dX | ||
|
|
||
| canvas.translate(mTextLeft.toFloat(), mTextTop.toFloat()) | ||
| canvas.translate(((mTextRight - mTextLeft) / 2).toFloat(), 0f) |
There was a problem hiding this comment.
| canvas.translate(((mTextRight - mTextLeft) / 2).toFloat(), 0f) | |
| canvas.translate(((mTextRight - mTextLeft) / 2), 0f) |
|
Please let me know if you need some support going forward 馃檹 |
Description
Prevent long texts to be covered by the slide icon button as well as gets cut off by supporting text-wrapping.
Used solution proposed by @Nealsoni00 and added ellipsis and dynamic max lines.
Related PRs/Issues
mText cutoff and wrapping issue #140
Screenshot
Used string

Sample SlideToActView veeeeeeeeeeeeeeeeeery looooong long loooooong looooooong looooooooong looooong text