1

I'm trying to create an EditText with custom background, and a compound drawable to the left, but outside the background (currently it's appearing overlapped to the background); something like this.-

enter image description here

Is this possible?

ssantos
  • 16,001
  • 7
  • 50
  • 70
  • 1
    anything that the EditText will draw must be inside it's view bounds. Those are the rules. But nothing stops you from bending the rules by making a clever background for the View that will have the orange pre-draw. – Budius Aug 25 '13 at 18:52
  • Thanks @Budius. The screenshot may be confusing, actually that orange color is the background of the whole layout, so I would rather prefer not to add it as part of the EditText background. Curious thing is, that I started with an Horizontal LinearLayout with one ImageView (the mail icon) and the EditText, and a warning suggested me to replace it for a single EditText+Drawable, so I assumed there's a direct way to achieve this. – ssantos Aug 25 '13 at 18:57
  • 1
    change my previous comment to 'transparent' instead of 'orange' then. But yeah, that warning doesn't know that you want the text box only around the text. I this case that you have a background might be safer instead of trying to adjust backgrounds in all different densities just use the horizontal LinearLayout and ignore the warning. – Budius Aug 25 '13 at 19:05
  • You're right, I'll stay with the LinearLayout's then. Thanks! – ssantos Aug 25 '13 at 19:09

1 Answers1

0

If your background is the white box - then no, it's not possible to draw outside of the TextView's bounds.

Although you can use a compound background, set the orange colour with the white box inside of it as your TextView's background, then you'll be able to set the mailbox as the left drawable of your TextView.

Adel Nizamuddin
  • 823
  • 14
  • 31