When I copy an email from a website and paste it in my edit text, it comes with the rich formatting and then I tried to remove the formatting 

```
public void afterTextChanged(Editable string)
{
    CharacterStyle[] toBeRemovedSpans = string.getSpans(0, string.length(),
                                                MetricAffectingSpan.class);
    for (int index = 0; index < toBeRemovedSpans; index++)
        string.removeSpan(toBeRemovedSpans[index]);
    }
}

```

[This image is before formatting](https://i.stack.imgur.com/EsZWE.jpg)

but it didn't worked for me like their is a huge gap from starting to the text.[This image is after applying the formatting](https://i.stack.imgur.com/GujmR.jpg)

I have gone through whole internet to stop it but didn't find anything.
I tried clearing all spans from edit text but it made edit text a way slow than before.

```
<LinearLayout
                    android:id="@+id/email_signup_form"
                    android:layout_width="match_parent"
                    android:layout_marginTop="20dp"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/SIZE_50"
                        android:paddingLeft="@dimen/activity_horizontal_margin"
                        android:paddingRight="@dimen/activity_horizontal_margin"
                        app:hintTextAppearance="@style/MyAppearance">

                        <EditText
                            android:id="@+id/first_name"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="@string/prompt_fname"
                            android:inputType="textPersonName"
                            android:maxLength="64"
                            android:maxLines="1"
                            android:singleLine="true"
                            />

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

                    <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingLeft="@dimen/activity_horizontal_margin"
                        android:paddingRight="@dimen/activity_horizontal_margin"
                        app:hintTextAppearance="@style/MyAppearance">

                        <EditText
                            android:id="@+id/last_name"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="@string/prompt_lname"
                            android:inputType="textPersonName"
                            android:maxLines="1"
                            android:maxLength="64"
                            android:singleLine="true" />

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

                    <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:paddingLeft="@dimen/activity_horizontal_margin"
                        android:paddingRight="@dimen/activity_horizontal_margin"
                        android:layout_height="wrap_content"
                        app:hintTextAppearance="@style/MyAppearance">

                        <EditText
                            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" />

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

                    <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/passwordText"
                        android:paddingLeft="@dimen/activity_horizontal_margin"
                        android:paddingRight="@dimen/activity_horizontal_margin"
                        app:passwordToggleEnabled="true"
                        app:hintTextAppearance="@style/MyAppearance">

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

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

                    <com.google.android.material.textfield.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/retypePasswordText"
                        android:paddingLeft="@dimen/activity_horizontal_margin"
                        android:paddingRight="@dimen/activity_horizontal_margin"
                        app:passwordToggleEnabled="true"
                        app:hintTextAppearance="@style/MyAppearance">

                        <EditText
                            android:id="@+id/cnf_password"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:hint="@string/prompt_password_cnf"
                            android:inputType="textPassword"
                            android:maxLines="1"
                            android:singleLine="true" />

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

                    <Button
                        android:id="@+id/email_sign_up_button"
                        style="?android:textAppearanceSmall"
                        android:layout_width="265dp"
                        android:layout_gravity="center"
                        android:background="@drawable/ripple_effect"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="16dp"
                        android:textColor="#fff"
                        android:text="@string/action_sign_up"
                        android:textStyle="bold" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center_horizontal|bottom">
                        <ImageView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:src="@drawable/characters"/>
                    </LinearLayout>

                </LinearLayout>

```

this problem is for every edit text. Thing is when I add text before pasting the text, edit text works without any gap or anything after text is pasted it works weird