About <AnnotatedString API> to have multiple style...
# compose
l
About AnnotatedString API to have multiple styles for a text, how to achieve it with a string resource? Let's say I have the following one:
<string name="news_count_title">{{count}} {{text}}</string>
. I would like
count
and
text
to have different styles. How to properly achieve it in Compose?
s
Not implemented in compose yet. :/ there is a ticket with title (~)Styled string resource
I didn't think much yet, but if i were to do it today i'd use Annotation class/tag in string resources and create an AnnotatedString from the Spanned i have.
l
Not implemented in compose yet. 😕 there is a ticket with title (~)Styled string resource
this one: https://issuetracker.google.com/issues/139320238 ?
s
Yes
Please feel free to star/vote it since we use votes in our prioritization
👍 1
l
I didn't think much yet, but if i were to do it today i'd use Annotation class/tag in string resources and create an AnnotatedString from the Spanned i have.
That's the solution I had in mind too 👍 I'm already using it to have clickable text inside a string. I was just hoping for something out of the box
c
I just released a library on top of the Compose AnnotatedString API to make this much easier https://github.com/copper-leaf/thistle
j
I'm quite happy with my solution: https://stackoverflow.com/a/69045782/1490484