I want to put an Icon inside an EditText
so I did like this:
android:drawableLeft="@drawable/search_icon"
The problem is that the image is bigger than the EditTex
t so the EditText
becomes bigger in order to fit the image size. What I want is the opposite: The image should resize in order to fit the EditText
height, is it possible?
I (desperately) tried with:
android:adjustViewBounds="true"
But obviously it doesn't work.
Is there any way to do so?
Try
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dd80aa"
android:orientation="vertical">
<RelativeLayout
android:layout_width="363dp"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter text here"
android:marginLeft="50dp"/>
<ImageView
android:layout_width="wrap_contenta"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="right"
android:src="@android:drawable/ic_menu_search"/>
</RelativeLayout>
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With