-
Notifications
You must be signed in to change notification settings - Fork 562
Spannable String clicks and other feedback #511
Comments
I'm a bit hesitant about adding clicks because of how easy it creates leaks. Although it's no different than using the Your syntax doesn't make sense in either context though. Our extensions are on a builder so the contents of the lambda are what is surrounded by the span. |
Thanks for the feedback. Sorry I didn't take the time to better understand the current API. I have a similar (much older) implementation that allowed for combining spans but I had forgot how exactly I did it I had to go back and look.
This solution let you set multiple spans on the same text (one CharacterStyle, ParagraphStyle, UpdateAppearance, UpdateLayout, TextAppearanceSpan (giving a resource int reference), and ClickableSpan (given an onClick lambda) So in my case the span dsl method had an argument of a Holder class which held all of the styles to apply to the builder for that text for each section.
So it looks like with your API we could have something like this.
The only other thing is I believe for ClickableSpans to work correctly the flag needs to be Spanned.SPAN_EXCLUSIVE_EXCLUSIVE |
Actually, the tricky part is that you need to set the LinkMovementMethod on the TextView for it to work for some reason. |
good |
Add ClickableSpan as part of the builder. It should be nestable in other spans. I am not exactly familiar what the DSL in ktx looks like for spannable strings but something like this should be possible. Looking at the code I think it would look something like this...
Also, it looks like you have to manually call append for each textStyle, I suggest adding a text attribute for each style instead.
The text was updated successfully, but these errors were encountered: