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.
Use the drawableStart
attribute:
https://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableStart
https://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawablesRelativeWithIntrinsicBounds(int,%20int,%20int,%20int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With