【问题标题】:drawableStart equivalent in TextField of Jetpack composeJetpack compose 的 TextField 中的 drawableStart 等效项
【发布时间】:2021-04-20 16:22:01
【问题描述】:

所以我在这里查看了这个文档https://developer.android.com/jetpack/compose/text#enter-modify-text

我已经设法使用以下方法创建了一个文本字段 (EditText):

@Composable
    fun EmailField() {
        var text by remember { mutableStateOf("") }

        TextField(
            colors = TextFieldDefaults.textFieldColors(
                textColor = Color.White,
                focusedIndicatorColor = Color.White,
                focusedLabelColor = Color.White
            ),
            value = text,
            onValueChange = { text = it },
            label = { Text("Email") }
        )
    }

现在我想设置我们在 XML 中的drawableStart。那么有没有这样的等价或其他方式来实现呢?

我想创建这样的东西:

感谢任何帮助或领导

【问题讨论】:

    标签: android android-jetpack-compose android-jetpack-compose-text


    【解决方案1】:

    使用1.0.0-beta06,您可以使用leadingIcon 属性:

    TextField(
        value = text,
        onValueChange = { text = it },
        leadingIcon = {
           Icon(Icons.Filled.Email,
            "contentDescription",
            modifier = Modifier.clickable { /* .. */})}
    )
    

    【讨论】:

      猜你喜欢
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-22
      • 2021-09-20
      • 2021-11-15
      • 2022-11-28
      • 1970-01-01
      • 2021-09-12
      相关资源
      最近更新 更多