https://kotlinlang.org logo
#compose
Title
# compose
k

Kazemihabib1996

05/23/2020, 3:38 PM
What's the equal of textView.setText(
(Html.fromHtml(htmlString , Html.FROM_HTML_MODE_LEGACY)));
in compose?
p

pardom

05/24/2020, 2:02 AM
Habib, have you made progress toward this? I'm also need to do this, but I've been putting it off.
k

Kazemihabib1996

05/24/2020, 7:04 AM
No actually I asked this out of curiosity as I couldn't find any API for that when I've been studying
AnnotatedStrings
I needed that for a Bullet thenI found
Copy code
with(DensityAmbient.current) {
            // this box is acting as a character, so it's sized with font scaling (sp)
            Box(
                modifier = Modifier
                    .preferredSize(8.sp.toDp(), 8.sp.toDp())
                    .alignWithSiblings {
                        // Add an alignment "baseline" 1sp below the bottom of the circle
                        9.sp.toIntPx()
                    },
                backgroundColor = contentColor(),
                shape = CircleShape
            )
        }
in JetNews sample.
p

pardom

05/24/2020, 5:05 PM
I see. I'm looking into the possibility of converting a
SpannedString
to an
AnnotatedString
👍 1
Then you can use it more generically, e.g. for
Html.fromHtml
or https://github.com/noties/Markwon
Doesn't look like
AnnotatedString
has an equivalent of
ClickableSpan
. It appears you can only style text.
a

Adam Powell

05/24/2020, 6:16 PM
A
SpannedString
to
AnnotatedString
is going to be a lossy conversion, AnnotatedString is deliberately less open-ended to avoid a bunch of issues we had with
SpannedString
👍 1
p

pardom

05/24/2020, 6:20 PM
Yeah,
SpannedString
is very open-ended 😆 I used it to implement Slack style tokenization once, which was neat, but felt unnerving considering the lack of an interface for spans.
a

Adam Powell

05/24/2020, 6:32 PM
not to mention the troubles that happen as soon as you want to parcel it.
🙃 1
12 Views