I want to place imageview inside edittext. Would it be possible? I checked \"evernote\" application, and it was able to put photo on the edittext part. I want to make my app
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/draw_bor"
android:drawableLeft="@drawable/icon"
android:inputType="phone"
android:hint="enter number"
android:padding="10dp"
android:textColorHint="#bbbbbb" />
you can use following property of editext
to set image in editext
android:drawableTop=""
android:drawableBottom=""
android:drawableRight=""
android:drawableLeft=""
android:drawableEnd=""
like this
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableTop="@mipmap/ic_launcher"
android:drawableBottom="@mipmap/ic_launcher"
android:drawableRight="@mipmap/ic_launcher"
android:drawableLeft="@mipmap/ic_launcher"
android:drawableEnd="@mipmap/ic_launcher"/>
or you can set drabble programatically like this
editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.drawableRight, 0);
Use this:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_text"
android:drawablePadding="8dp"
android:drawableRight="@drawable/yourImage"/>
you can use drawable left,right,top or bottom of your text according to your need.
To manipulate in java use this:
EditText editText = (EditText) findViewById(R.id.yourEditTextId);
editText.setCompoundDrawablesWithIntrinsicBounds(left,top,right,bottom);
for manipulating image set on right:
editText.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.yournewimage,0);
similarly you can do it for other cases.
Hope it helps!!!