Skip to content

Instantly share code, notes, and snippets.

@mirjalal
Created October 30, 2023 07:42
Show Gist options
  • Save mirjalal/8e281cdbcca9dba351a95d0a823afb3c to your computer and use it in GitHub Desktop.
Save mirjalal/8e281cdbcca9dba351a95d0a823afb3c to your computer and use it in GitHub Desktop.
bullet list for compose
val htmlString = stringResource(id = R.string.html_string)
val bullet = "\u2022"
val messages = HtmlCompat.fromHtml(htmlString, HtmlCompat.FROM_HTML_MODE_COMPACT).split('\n').toMutableList()
messages.removeIf { it.isEmpty() }
Text(
buildAnnotatedString {
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append(messages.removeFirst())
}
messages.forEach {
withStyle(style = ParagraphStyle(textIndent = TextIndent(restLine = 12.sp))) {
append(bullet)
append("\t\t")
append(it)
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment