Jetpack compose 的 TextField 中的 drawableStart 等效项 [英] drawableStart equivalent in TextField of Jetpack compose

查看:41
本文介绍了Jetpack compose 的 TextField 中的 drawableStart 等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在这里查看了这个文档

感谢任何帮助或领导

解决方案

使用 1.0.0-beta06 你可以使用 leadingIcon 属性:

TextField(值 = 文本,onValueChange = { text = it },领先图标 = {图标(Icons.Filled.Email,内容描述",修饰符 = Modifier.clickable {/* .. */})})

So I was checking out this document here https://developer.android.com/jetpack/compose/text#enter-modify-text

I have managed to create a text field (EditText) Using:

@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") }
        )
    }

Now I want to set the drawableStart which we had in XML. So is there any such equivalent or other way to achieve?

I want to create something like this:

Any help or lead is appreciated

解决方案

With 1.0.0-beta06 you can use the leadingIcon attribute:

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

这篇关于Jetpack compose 的 TextField 中的 drawableStart 等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆