Search code examples
androidalignmentmaterial-designmaterial-components-androidandroid-textinputedittext

change spaces of bottom line in TextInputEditText


I was working on a design that requires all views has an alignment to left.

I'm using TextInputLayout && TextInputEditText there was spaces for hint & text that are solved by setting padding to 0dp for TextInputEditText but, I'm stuck in removing padding/margin start for the bottom line of TextInputEditText.

so, can anyone help me with that simple issues, please?

enter image description here

actual, what I need to do is remove the space at the start of TextInputEditText so bottom line be aligned to left like E

this is my XML

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="@dimen/_5sdp"
            android:paddingBottom="@dimen/_5sdp"
            app:endIconDrawable="@mipmap/clear_email"
            app:endIconMode="clear_text"
            app:endIconTint="@color/grey"
            app:errorEnabled="true"
            app:hintEnabled="false">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/test"
                style="@style/TILStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="@font/opensans_regular"
                android:hint="@string/enter_email_address"
                android:importantForAutofill="no"
                android:inputType="textEmailAddress"
                android:theme="@style/Theme.App.Base"
                app:hintTextAppearance="@style/TextLabel" />

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

for the styles used: TILStyle

<style name="TILStyle">
    <item name="android:lines">1</item>
    <item name="android:singleLine">true</item>
    <item name="android:gravity">start</item>
    <item name="android:textAlignment">viewStart</item>
    <item name="android:paddingEnd">0dp</item>
    <item name="android:paddingStart">0dp</item>
    <item name="android:paddingBottom">@dimen/_12sdp</item>
</style>

Theme.App.Base

<style name="Theme.App.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorControlNormal">@color/grey_line</item>
    <item name="colorControlActivated">@color/grey_line</item>
    <item name="colorControlHighlight">@color/grey_line</item>
</style>

TextLabel

<style name="TextLabel" parent="TextAppearance.Design.Hint">
    <item name="android:textSize">16sp</item>
    <item name="android:paddingBottom">@dimen/_18sdp</item>
</style>

Solution

  • after long of search and debugging, I found that the issue in these two lines

     <item name="android:paddingEnd">0dp</item>
     <item name="android:paddingStart">0dp</item>
    

    after deleting them it's solved.

    it looks like that there is a default value for it, but I don't know how much are they but, that solved my issue.

    if anyone knows the default values please leave a comment.