Search code examples
androidtextviewdrawablevertical-alignment

Android align drawable left to the first line of my textView


I have a textView in which I put some text (obviously) and a Drawable left. Unfortunately, when I use phones with small screens like a Samsung Galaxy Y, instead of just a single line, the text runs over to a second line. (which is fine). However, the drawable that I set now aligns itself to the center of the textview, and not on the left of the first line.

I want my drawable to stay aligned to the first line of text in my textview, no matter how many lines of text, my textview holds. Is there a way to do this? Can anyone point me in the right direction?

my implementation is pretty straightforward

...
tv.setCompoundDrawables(drawableLeft, null, null, null);

where my drawableLeft is the image from my drawable folder.

Thanks a lot!


Solution

  • Try to use a drawable like a separate view (ie ImageView) and not to set it as a tag in a TextView. Using that will grant you more control over the drawable/ImageView it self.