EditText leftView图像适合EditText Android的大小

LS_*_*LS_ 5 java android android-edittext

我想把一个Icon放在里面,EditText所以我喜欢这样:

android:drawableLeft="@drawable/search_icon"
Run Code Online (Sandbox Code Playgroud)

问题是图像比EditText EditText大,所以为了适应图像尺寸,图像变大.我想要的是相反的:图像应调整大小以适应EditText高度,是否可能?

我(拼命地)尝试:

android:adjustViewBounds="true"
Run Code Online (Sandbox Code Playgroud)

但显然它不起作用.

有没有办法这样做?

She*_*han 2

尝试

<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>
Run Code Online (Sandbox Code Playgroud)