I want to add suffix to TextInputLayout. An example is taken from the material.io
Are there any standard solutions?
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.
Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it. Works back and forth.
With the TextInputLayout
provided in the Material Components Library you can use the attrs:
app:prefixText
: prefix textapp:suffixText
: suffix textSomething 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:
Note: This requires a minimum of version 1.2.0-alpha01
.
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