Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextInputLayout suffix/prefix [duplicate]

I want to add suffix to TextInputLayout. An example is taken from the material.io

Example

Are there any standard solutions?

like image 774
negatiffx Avatar asked Apr 06 '17 17:04

negatiffx


People also ask

What is TextInputLayout?

Android App Development for Beginners Before getting into example, we should know what is TextInputLayout in android. TextInputLayout is extended by Linear Layout. It going to act as a wrapper for edit text and shows flatting hint animation for edit text.

How do I remove TextInputLayout error?

Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it. Works back and forth.


1 Answers

With the TextInputLayout provided in the Material Components Library you can use the attrs:

  • app:prefixText: prefix text
  • app:suffixText: suffix text

Something like:

<com.google.android.material.textfield.TextInputLayout
    android:hint="Test"
    app:prefixText="@string/..."
    app:prefixTextColor="@color/secondaryDarkColor"
    app:suffixText="@string/..."
    app:suffixTextColor="@color/primaryLightColor"
    ...>

    <com.google.android.material.textfield.TextInputEditText
        .../>

</com.google.android.material.textfield.TextInputLayout>

Example:

enter image description here

Note: This requires a minimum of version 1.2.0-alpha01.

like image 155
Gabriele Mariotti Avatar answered Oct 12 '22 03:10

Gabriele Mariotti