jasu
11/09/2023, 5:41 AM"label": "<span style=\"font-size: 12px;\">14/20</span> Orders completed"
and would like to render text where 14/20 is bigger than restascii
11/09/2023, 1:36 PMbuildAnnotatedString {
// Defer to platform via androidx.core.text.HtmlCompat
append(HtmlCompat.fromHtml(html, flags).toString())
// Apply default span & paragraph styles
val length = spanned.length
val textStyle = LocalTextStyle.current
val spanStyle = textStyle.toSpanStyle()
addStyle(spanStyle, 0, length)
addStyle(textStyle.toParagraphStyle(), 0, length)
val defaultFontSize = spanStyle.fontSize
spanned.getSpans<Any>().forEach { span ->
val start = spanned.getSpanStart(span)
val end = spanned.getSpanEnd(span)
when (span) {
is RelativeSizeSpan -> SpanStyle(fontSize = defaultFontSize * span.sizeChange)
// ^ this is what you want
// … other spans
}.let {
addStyle(it, start, end)
}
}
}
font-size: larger
or something like that. Leave it to the client (app or website) to style it accordingly.
Or you know, you could refactor your response to not be in HTML at all. The example you gave doesn't need HTML (return numbers & suffix string as separate fields).jasu
11/10/2023, 1:03 PMAbsoluteSizeSpan
any idea about that?