BBNN
BBNN

Reputation: 33

Android TextInputLayout - no space below bottom line

I've created text input using TextInputLayout and TextInputEditText. TextInputLayout should have gray background and editText line should be on the bottom without any margin. I tried with 0 margins and padding, but I didn't manage how to do that.

How it looks like:

How it looks like

What I need:

What I need

Upvotes: 0

Views: 1271

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 365048

Just use the standard TextInputLayout in the Material Components library.

   <com.google.android.material.textfield.TextInputLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="Hint">

       <com.google.android.material.textfield.TextInputEditText
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="Text"/>

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

enter image description here

Upvotes: 2

ter
ter

Reputation: 16

Create a drawable file bg_edittext.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle">
            <stroke android:width="1dp" android:color="#000"/>
        </shape>
    </item>
    <item android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="#fff"/>
        </shape>
    </item>

</layer-list>

and go to your edittext, set

 android:background="@drawable/bg_edittext"

Upvotes: 0

Related Questions