Set actual text padding in TextView with compound drawables

Gio picture Gio · Sep 17, 2012 · Viewed 17.7k times · Source

I have a ListView populated with an ArrayAdapter. For items I use just a single TextView layout. I want some of the rows to have compound drawables set.

Question: is there a way to set padding for the actual text that is contained in TextView so that the compound drawables don't get the padding too? Other solution would be to lock the width of text. Do I need to add ImageViews to my layout?

Answer

Ornithopter picture Ornithopter · Jun 19, 2013

Quite simple:

android:drawablePadding="5dp"

It will automatically use the padding according to the direction.