1

I am using the EditText with drawableLeft property and set ImageView in Left side for displaying mobile icon. My Question is how to put Imageview in EditText?

Please help me.

Actually i want like this.

I have tried using linear layout with horizontal. below is xml code.

<LinearLayout
       android:weightSum="2"
       android:layout_below="@id/welcome"
       android:orientation="horizontal"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">

        <de.hdodenhof.circleimageview.CircleImageView
            android:layout_weight="1"
            android:layout_gravity="center"
            android:id="@+id/image_mobile"
            android:layout_width="@dimen/_50sdp"
            android:layout_height="@dimen/_50sdp"
            android:src="@mipmap/ic_launcher" />


        <EditText
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_30sdp"
            android:layout_toRightOf="@+id/image_mobile"
            android:hint="Mobile number"
            android:inputType="text" />

   </LinearLayout>

But am not able to adjust the image view and edittext.

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
santosh nani
  • 147
  • 3
  • 11
  • you can use left_drawable with edittext if you just to want to display any image with it – Quick learner Sep 04 '18 at 09:25
  • the easy way to get your desired look is set a drawable to your linearlayout and it will give the impression of exactly what you want. – Umair Sep 04 '18 at 09:27

1 Answers1

0

You should use android:drawableStart

The drawable to be drawn to the start of the text.

DEMO

<EditText
     ......
     android:drawableStart="@drawable/your_icon"
     android:drawablePadding="5dp"
    />
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198