1

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
Rakki s
  • 1,426
  • 1
  • 18
  • 42

2 Answers2

5

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

enter image description here

Hristova
  • 156
  • 1
  • 6
  • But my requirement is after some height i have to show text in normal position (Not after image width) – Rakki s Jul 25 '14 at 09:18
  • I know, but I don't think there is a standard way to do this. – Hristova Jul 25 '14 at 11:17
  • Cool Thank you. I am using spanable text to set some leading space for editext with some fixed line and i added image in separate imageview over the edittext. but still i have some problem with gravity . We will wait for some one to answer a standard way. – Rakki s Jul 31 '14 at 07:12
0

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

  • Thanks for you answer .Your code will add image in left ,top ,right or bottom my requirement is once the image height reached mean i need to show text normally. If i am wrong mean can you please explain with some code. – Rakki s Jul 31 '14 at 07:22
  • you can implement the corresponding view by using the linear layout as: Put image in image view and set text in rest of the screen and another edit Text below it. Set background transparent of both edit text and your view appears.... – Gaurav Mittal Jul 31 '14 at 12:03
  • The problem is we have to give editiext box user can able to edit the text. – Rakki s Jul 31 '14 at 12:12
  • yes that right , u can do it like image view first, then edit text ,both having same height. After that one edit text below linear layout, and set background transparent.and put all this layout in one linear layout and set a background image like edit text. – Gaurav Mittal Jul 31 '14 at 13:16
  • Ok but i have problem while the user types in edittext 1. How to know the first edittext reached it maximum character(means reached it height) 2.How to switch focus to next edittext. – Rakki s Aug 01 '14 at 09:07
  • yes, in that case you can ask for setting a edit text max lines 3 as when user writes 3 lines press enter focus automatically comes to next one.. – Gaurav Mittal Aug 01 '14 at 12:18