Sudhanshu.B
Sudhanshu.B

Reputation: 636

How to remove underline from drawableLeft android

Hi I am using an editText and added drawableLeft for image. But underline is coming below image aswell.

enter image description here

I am using below code:

 <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_add_black_24dp"
            android:hint="@string/email"
            android:drawablePadding="10dp"
            android:layout_marginTop="10dp"/>

 <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_add_black_24dp"
            android:hint="@string/password"
            android:drawablePadding="10dp"
            android:layout_marginTop="10dp"
            android:inputType="textPassword"/>

Please suggest how to remove Underline which is coming below drawableLeft(image).

Upvotes: 1

Views: 126

Answers (2)

Asteroid
Asteroid

Reputation: 758

Try this.Maybe it will help you.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:src="@drawable/ic_lock_black_24dp" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="password" />

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

</LinearLayout>

Upvotes: 1

Mehul Kabaria
Mehul Kabaria

Reputation: 6622

There is not any straight forward way to get this thing in EditText.

you get this using like below.

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/text_white"
        android:orientation="horizontal">

    <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_margin="@dimen/_10sdp"
            android:src="@drawable/ic_email"
            android:tint="@color/black"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/_10sdp"
            android:hint="email"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/imageView"
            app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Output

enter image description here

Upvotes: 1

Related Questions