Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add an image on EditText

I want to dynamically add image in EditText. Is it possible?

if anyone knows please give sample code for that.

like image 242
sivaraj Avatar asked Sep 13 '10 18:09

sivaraj


People also ask

How do I add an icon to EditText?

2- First thing we need to do is to look for icons that we can use them for the android edittext. Right click on res folder → New → Vector Asset . Adjust the size from (24dp x 24dp) to (18dp x 18dp), choose the icon that you want by clicking on the android icon, click “Next” button and then click “Finish”.

How can I add image in Android Studio?

To import image resources into your project, do the following: Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import.


Video Answer


1 Answers

If something like this:

EditCheck

is what you're talking about, then you just need to either set the Drawable{Right | Left | Top | Bottom} property in the xml, or call the corresponding java command.

EditText text = (EditText)findViewById(R.id.text); text.setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.check_box), null); 
like image 120
CaseyB Avatar answered Sep 19 '22 16:09

CaseyB