Ad

Remove Extra Padding/margin From TextInputLayout SetError Text

- 1 answer

I am using TextInputLayout to show error with EditText. All is working good. I have to remove extra space from TextInputLayout's error text.

So far I had did this,

<android.support.design.widget.TextInputLayout
                android:id="@+id/txt_error_passowrd"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                app:errorEnabled="true"
                app:passwordToggleEnabled="true"
                app:passwordToggleTint="@color/colorAccent"
                app:errorTextAppearance="@style/error_appearance"
                app:hintTextAppearance="@style/EditHintText">

                <android.support.design.widget.TextInputEditText
                    android:id="@+id/edit_password"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/views_height"
                    android:fontFamily="@font/roboto_light"
                    android:hint="@string/password"
                    android:inputType="textPassword"
                    android:paddingLeft="10dp"
                    android:textColorHint="@color/light_text_color"
                    android:textSize="@dimen/font_14sp" />

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

And inside style.xml I had use this

 <style name="EditHintText" parent="TextAppearance.Design.Hint">
    <item name="android:textSize">@dimen/font_10sp</item>
    <item name="android:textColor">@color/dark_text_color</item>
</style>

<style name="error_appearance" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/red</item>
    <item name="android:textSize">@dimen/font_10sp</item>
</style>

I have attached screen shot. Please help

Ad

Answer

Try removing this line android:paddingLeft=10dp from TextInputEditText, as there is no padding in TextInputLayout this EditText padding may be causing the problem also why are you using android:layout_weight=1 for TextInputLayout when none of its height or width is set to 0dp.

Ad
source: stackoverflow.com
Ad