2013-03-13 40 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) 

方法。

乾杯