How to Add Padding to a Drawable in a TextView, in XML
android:drawablePadding was added in API Level 1Related Method: setCompoundDrawablePadding - Add Padding to a Drawable in a TextView, using Java
1. Add a TextView in your main.xml file.
2. Add the following text to the TextView: "This is an example with a drawable set to the left in a TextView."
3. Add a drawable to the TextView.
Examples include:
android:drawableBottom, android:drawableEnd, android:drawableLeft, android:drawableRight.
(My example will use android:drawableLeft)
4. In the main.xml file, add the code below.
<TextView
...
android:drawablePadding = "15dip"
/>
5. Compile and run!
6. You can compare the image above to without android:drawablePadding here, using android:drawableLeft.
Related Articles:
Resources: