2013-03-13 115 views
5

我想将图像放在EditText字段中,如图所示。应该怎么做呢?在一层上的图像分层列表和在另一层上的EditText左侧的大量填充?如何将图像放入EditText字段?

enter image description here

+1

看看这个问题:http://stackoverflow.com/questions/3703283/how-can-i-add-an-image-on-edittext – ebarrenechea 2013-03-13 18:30:04

+0

解决问题的链接是Java。这个答案值得称道,因为它可以用XML解决。 – nipponese 2013-03-13 20:19:26

回答

8

在editText中设置图像。

<EditText 
    ...... 
    android:drawableLeft="@drawable/image" /> 

您可以将它设置为左,右,上,下。

1

只需使用

setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) 

setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) 

方法。

干杯