在edittext android中插入imageview

我想将imageview放在edittext中。 可能吗? 我检查了“evernote”应用程序,它能够将照片放在edittext部分。 我想让我的应用程序完全一样。 我如何能够放置从图库中选择的imageview,并将照片放在edittext中?

我首先尝试将imageview放在.xml文件中的relativelayout中,但它给了我一个错误标志。

我应该在.xml文件上吗? 或者我应该制作自己的edittext java文件才能做到这一点?

用这个:

  

您可以根据需要使用文本的左侧,右侧,顶部或底部。

要在java中操作,请使用:

 EditText editText = (EditText) findViewById(R.id.yourEditTextId); editText.setCompoundDrawablesWithIntrinsicBounds(left,top,right,bottom); 

用于操作右侧的图像集:

 editText.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.yournewimage,0); 

同样地,你可以为其他情况做这件事。

希望能帮助到你!!!

  1. 你可以在图像中尝试这个编辑文本
   

您可以使用editext以下属性在editext中设置图像

 android:drawableTop="" android:drawableBottom="" android:drawableRight="" android:drawableLeft="" android:drawableEnd="" 

像这样

  

或者你可以像这样以编程方式设置drabble

 editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.drawableRight, 0);