TextInputLayout Disable Hint Animation – Fix

TextInputLayout Disable Hint Animation – This may seem counterintuitive, but is there a way to disable or remove the floating caption tooltip in TextInputLayout? The reason I want to use TextInputLayout instead of a simple EditText is the counter that TextInputLayout offers.

TextInputLayout Disable Hint Animation

TextInputLayout Disable Hint Animation

Here’s what I’ve got so far:

How can I solve this TextInputLayout Disable Hint Animation problem?

Solution 1:

As of version 23.2.0 of the support library, you can setHintEnabled (fake) or define it as such in the XML TextInputLayout : app:hintEnabled=false Although the name suggests that this removes all clues, only the hover is removed.

  • Related documents and questions: http://developer.android.com/reference/android/support/design/widget/TextInputLayout.html#setHintEnabled (boolean).
  • https://code.google.com/p/android/issues/detail?id=181590

Solution 2:

There are three ways to do this: 1 Set android:hint in TextInputLayout to the _ space, and keep android:hint=This is my great set of tips in EditText.

This works because TextInputLayout performs the following check before using the EditText index:

  • // If we don’t have a valid index, try taking it out of EditText
    as (TextUtils.isEmpty(mHint)) {
    // delete the EditText index, because we will display it ourselves

By setting android:hint=, if (TextUtils.isEmpty(mHint)) evaluates to false, and EditText retains its index. 2 The second option would be to subclassify TextInputLayout and replace the addView method (View child, int index, ViewGroup.LayoutParams params) :

  • the public class CTextInputLayout expands the class TextInputLayout {
  • public CTextInputLayout(Context) {
    this(context, zero);
  • public CTextInputLayout(Context, AttributeSet attrs) {
    this(context, attrs, 0);
  • public CTextInputLayout(Context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  • @Overridepublic void addView(View child, int index, ViewGroup.LayoutParams params) {as (EditText child instance) {/ hides current indexCharSequence hint = ((EditText)child).getHint();// removes the index for now – we don’t want the TextInputLayout to see the((EditText)child).setHint(null);// let `TextInputLayout` doensuper.addView(child, index, params);// finally reset the index((EditText)child).setHint(hint);} other {// continue adding the viewsuper.addView(child, index, parameter);}}}}.

Then use your own CTextInoutLayout instead of the Design Support Library :

3 The third and perhaps easiest way would be to make the following calls:

// remove index from `TextInputLayout`
// return index to `EditText`
// pass `String` can also be a
string source ((EditText)findViewById(R.id.myEditText)).setHint(This is my class index;)

Solution 3:

With com.google.android.material, you can hide

Solution 4:

I’ve tried all the answers, but they don’t all work now (especially for com.google.android.material:material:1.1.0-beta01). Even if we make changes to the logic of adding EditText to the TextInputLayout, we have an empty area above the field that blocks half of the text and the tooltip. I now have a solution to the problem. The most important thing is the filling in EditText, as mentioned in material.io :

This allows us to set a SearchView type view with a search icon and a delete text button, without all the magic of custom views.

Solution No 5:

If you use the app:hintEnabled=false, you also set android:paddingTop=8dp in EditText, and the space for top hints disappears, it worked for me, and I hope it works for you too.

Solution No 6:

myEditText.setOnFocusChangeListener { _, hasFocus ->
as (hasFocus) textContainer.hint = null
else myEditText.hint = getString(R.string.your_string)

This makes your hint in text input layout perfect, because if you want to make it disappear with the app:hintEnabled=false, it doesn’t make your text input layout cool.

Solution No 7:

To apply a style to your EditText, add the following code to the file Styles.xml …

For the background effect, create edittext_background.xml in the rendered form.

Solution No 8:

If someone has a problem like me:

Insect repellent

The sticker doesn’t fill in the text correctly, so do it:

Adding padding to the top and bottom of TextInputEditText solves the problem.

Solution No 9:

The answer of @Gauthier is correct, but if you want not only a floating hint but also a hint for editing text, you have to enter a hint in the EditText widget next to disabling the hint for TextInputLayout.

I think this is an answer to some of the questions asked by some people in the comments above.

Solution No 10:

I think this will help you:

text container.setHintAnimationEnabled(false) ;

Also Check: Best Phone for Rooting

Good luck! hope you can fix the TextInputLayout Disable Hint Animation issue easily now.