Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android material design: remove hint animation

I am building an app that has some AutoCompleteTextView, using amterial design AppCompat. I need to remove the hint animation that this component has, when you tap on the field and the hint goes up, in a smooth animation. Is there any way to remove this animation?

My layout:

<!-- Login progress -->
<ProgressBar android:id="@+id/login_progress" style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:layout_marginBottom="8dp" android:visibility="gone" />

<LinearLayout android:id="@+id/login_form"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

    <LinearLayout android:id="@+id/email_login_form" android:layout_width="match_parent"
        android:layout_height="match_parent" android:orientation="vertical">

        <android.support.design.widget.TextInputLayout android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <AutoCompleteTextView android:id="@+id/email" android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_email"
                android:inputType="textEmailAddress"
                android:maxLines="1"
                android:singleLine="true"
                android:theme="@style/AutoCompleteTextViewListasVipHolo" />

        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText android:id="@+id/password" android:layout_width="match_parent"
                android:layout_height="wrap_content" android:hint="@string/prompt_password"
                android:imeActionId="@+id/login"
                android:imeActionLabel="@string/action_sign_in_short"
                android:imeOptions="actionUnspecified" android:inputType="textPassword"
                android:maxLines="1" android:singleLine="true" />

        </android.support.design.widget.TextInputLayout>

        <Button android:id="@+id/email_sign_in_button"
            style="?android:textAppearanceSmall"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="@string/action_sign_in"
            android:textStyle="bold" />

        <Button android:id="@+id/register_button"
            style="?android:textAppearanceSmall"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:text="@string/action_register"
            android:textStyle="bold" />

    </LinearLayout>
</LinearLayout>

I don´t want to lose the auto complete feature.

like image 908
erickles Avatar asked Nov 13 '15 11:11

erickles


2 Answers

If you want to remove the floating label, then remove the TextInputLayout wrapping around your AutoCompleteTextView. This will remove the floating label feature.

If you want the floating label, but disable the animation, then with the support design library v23 you can use textInputLayout.setHintAnimationEnabled(false); in your code

or app:hintAnimationEnabled="true" as a parameter to the TextInputLayout in XML.

like image 134
Alok Nair Avatar answered Nov 10 '22 12:11

Alok Nair


It can be done programmatically very easily by doing the steps below.

  1. Set textInputLayout's hint to null
textInputLayout.setHint(null);
  1. Set TextInputEditText's hint to your hint text
EditText editText = textInputLayout.getEditText();
editText.setHint("your hint text");
like image 1
Prashant Paliwal Avatar answered Nov 10 '22 13:11

Prashant Paliwal