How to disable floating while showing error in TextInputLayout

Viewed 2827
<android.support.design.widget.TextInputLayout
        android:id="@+id/productLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:errorEnabled="true">

  <EditText
      android:id="@+id/product"
      android:layout_width="match_parent"
      android:layout_height="@dimen/margin_padding_width_height_6"
      android:cursorVisible="false"
      android:drawableRight="@drawable/ic_arrow_down"
      android:focusableInTouchMode="false"
      android:hint="@string/product"
      android:inputType="none"
      android:paddingEnd="@dimen/margin_padding_width_height_2"
      android:paddingRight="@dimen/margin_padding_width_height_2"
      android:singleLine="true"
      android:textSize="@dimen/text_size_m" />

private boolean validateFields() {
        if (mCategory.getText().toString().isEmpty())
            mCategoryLayout.setError("Please select a category");
        else if (mProducts.getText().toString().isEmpty())
            mProductsLayout.setError("Please select a product");
        else if (mSerialNumber.getText().toString().isEmpty())
            mSerialNumberLayout.setError("Please enter the serial number");
        else
            return true;
        return false;
    }

I have implemented click listener for the EditText,So I don't want float the EditText label to top while setting error on TextInputLayout. How do I disable that ?

4 Answers
Related