-->

How to add a image inside a edit text android [dup

2019-08-07 11:09发布

问题:

This question already has an answer here:

  • how to insert image to a editText 6 answers

I want to add image inside edittext view . For example i have image that size is 250*250 i want to show text left to image for height of 250 after that have to show text in normal left position.

               Some text some text some text
  Some image   Some text some text some text
               Some text some text some text
Some text some text some text Some text some 
text some text some text some text Some text 
some text Some text some text Some text some

回答1:

You can use the xml property android:drawableLeft or (as mentioned) setCompoundDrawableWithinBounds. But your EditText will look something like this:



回答2:

You can add image in editext programmatically using setCompoundDrawableWithinBounds set drawable at left...