0

I am trying to set padding and margin for Edittext border to place the icon on drawable Left, but am not able to achieve as expected.

Please help

Below is my xml Code:

<EditText
            android:id="@+id/EtMobile"
            android:layout_width="match_parent"
            android:layout_height="@dimen/_40sdp"
            android:layout_below="@id/pleaseLogin"
            android:layout_marginTop="@dimen/_10sdp"
            android:background="@drawable/btn_oval_shape"
            android:drawableLeft="@mipmap/ic_login_mobile"
            android:drawablePadding="@dimen/_10sdp"
            android:hint="Mobile number"
            android:inputType="text"/>

Actually I want like this:

Login_screen

My result is:

custom_login_screen

santosh nani
  • 147
  • 3
  • 11

2 Answers2

1

Instead of placing as a DrawableLeft, I suggest you to take an ImageView ... So that you can have more control on the image.

You can have many functionalies with ImageView, but in EditText you cannot.

Lastly, place them both in RelativeLayout.

Hopefully it will work as expected.

Ümañg ßürmån
  • 9,695
  • 4
  • 24
  • 41
0

just put padding inside your btn_oval_shape.xml. Put inside your shape code:

<padding
android:bottom="3dp"
android:top="3dp"
android:left="3dp"
android:right="3dp"/>