How to create bulleted text list in Android Jetpack compose?
I want something like this :
- Hey This is first paragraph.
- Hey this is my second paragraph. Any this is 2nd line.
- Hey this is 3rd paragraph.
I don't know if it can meet expectations,please try
@Preview(showBackground = true)
@Composable
fun TestList() {
val list = listOf(
"Hey This is first paragraph",
"Hey this is my second paragraph. Any this is 2nd line.",
"Hey this is 3rd paragraph."
)
LazyColumn {
items(list) {
Row(Modifier.padding(8.dp),verticalAlignment = Alignment.CenterVertically) {
Canvas(modifier = Modifier.padding(start = 8.dp,end = 8.dp).size(6.dp)){
drawCircle(Color.Black)
}
Text(text = it,fontSize = 12.sp)
}
}
}
}
Found it while brainstorming. Just another approach with annotated string and only one Text.
val bullet = "\u2022"
val messages = listOf(
"Hey This is first paragraph",
"Hey this is my second paragraph. Any this is 2nd line.",
"Hey this is 3rd paragraph."
)
val paragraphStyle = ParagraphStyle(textIndent = TextIndent(restLine = 12.sp))
Text(
buildAnnotatedString {
messages.forEach {
withStyle(style = paragraphStyle) {
append(bullet)
append("\t\t")
append(it)
}
}
}
)