Cod*_*kas 18 android android-compose-textfield
我想要这样的东西:
\n\xe2\x80\xa2 Hey this is my first paragraph.\n\xe2\x80\xa2 Hey this is my second paragraph.\n And this is the second line.\n\xe2\x80\xa2 Hey this is my third paragraph.\nRun Code Online (Sandbox Code Playgroud)\n
Cod*_*kas 27
头脑风暴的时候发现的。这只是另一种带有注释字符串和只有一个文本的方法。
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)
}
}
}
)
Run Code Online (Sandbox Code Playgroud)
不知道是否能达到预期,请尝试一下
@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)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8992 次 |
| 最近记录: |