I am trying to insert an icon in the beginning of a Material Text Field. I couldn't find anything suitable in material.io's documentation as well.
This is what I am trying to achieve.
I am trying to insert an icon in the beginning of a Material Text Field. I couldn't find anything suitable in material.io's documentation as well.
This is what I am trying to achieve.
Use a TextInputLayout
with the app:startIconDrawable
<com.google.android.material.textfield.TextInputLayout
android:hint="Select Time"
app:startIconDrawable="@drawable/ic_add_24px"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
../>
</com.google.android.material.textfield.TextInputLayout>
Note: it requires the version 1.1.0 of the library.
app:startIconDrawable
attribute doesn't work for me. The icon does not show up in design view, and I get an error like this: AAPT: error: attribute app:startIconDrawable not found.
Besides this, the material component library seems to work fine. –
Nobleminded 1.0.0
. Updated to 1.2.0-alpha01
, but now I lost the whole material style. All I can see is the default AppCompat style on the layout design. –
Nobleminded 1.1.0-beta01
as well. Same result. I use the material component theme. Everything was fine (except the icon) with 1.0.0
. –
Nobleminded startIconDrawable
padding? –
Goatee Use the drawableStart
attribute:
https://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableStart
step 1: copy required Text field
Material text field doc : https://material.io/components/text-fields/android#using-text-fields
step 2: select text field -> search "draw" -> Click drawableLeft icon
step 3: Select or Add icon (I'll select vector icon)
© 2022 - 2024 — McMap. All rights reserved.