如何在Jetpack Compose中创建多行文本区域

huangapple go评论66阅读模式
英文:

How to create multiline text area in jetpack compose

问题

我想创建以下文本字段。但是在互联网上没有相同的示例,也没有材料文档。

英文:

I want to create the following textfield. But there are no samples on the internet for the same, neither in material documentation
如何在Jetpack Compose中创建多行文本区域

答案1

得分: 5

@Composable
fun Textarea() {
    val text = rememberSaveable { mutableStateOf("") }
    TextField(
        value = text.value,
        onValueChange = { text.value = it }, modifier = Modifier
            .fillMaxWidth()
            .height(100.dp)
            .padding(10.dp)
            .border(width = 1.dp, color = Color.Black, shape = RoundedCornerShape(8.dp))
    )
}

您可以根据需要更改大小并进行自定义。

英文:
  @Composable
    fun Textarea() {
    val text = rememberSaveable { mutableStateOf("") }
    TextField(
        value = text.value,
        onValueChange = { text.value = it }, modifier = Modifier
            .fillMaxWidth()
            .height(100.dp)
            .padding(10.dp)
            .border(width = 1.dp, color = Color.Black, shape = RoundedCornerShape(8.dp))
    )
}

You can change the size and customize it as you want as per your requirement.

huangapple
  • 本文由 发表于 2023年2月6日 12:08:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75357258.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定