平时都不怎么注意,今天在一个应用中要在EditText里放入图片,类似于在EditText的hint属性一样,主要达到hint提示文字前面还多了一张图片,如果你也遇到相同的问题,你只要使用EditText的drawableLeft属性就尅实现了,不用再去自定义:具体如下:
、
直接用drawaableLeft属性就可以实现了,具体如下所示,
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="请输入关键字"
android:background="@android:drawable/editbox_background"
android:drawableLeft="@android:drawable/ic_menu_search" />
这样就可以简单的实现类似于搜索框一样的EditText了