I want to dynamically add image in EditText
. Is it possible?
if anyone knows please give sample code for that.
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”.
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.
If something like this:
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With