如何在edittext中设置ImageView

How to set ImageView in edittext

我正在使用带有 drawableLeft 的 EditText 属性 并在左侧设置 ImageView 以显示移动图标。我的问题是如何把Imageview放到EditText中?

请帮帮我

其实我想要这样

我试过使用水平的线性布局。下面是 xml 代码。

<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>

但是我无法调整图像视图和编辑文本。

你应该使用android:drawableStart

要绘制到文本开头的可绘制对象。

演示

<EditText
     ......
     android:drawableStart="@drawable/your_icon"
     android:drawablePadding="5dp"
    />