android:drawableLeft - Set a Drawable to the left of text, in a TextView, in XML

How to Set a Drawable to the left of the text, in TextView, in XML

android:drawableLeft was added in API Level 1 
Related Method: setCompoundDrawablesWithIntrinsicBounds - Add a Drawable to the Left of the text in a TextView, in Java

The drawable to be drawn to the left of the text.

1. Add a TextView.

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 named myImage.  

4. In the main.xml file, add the below line

  <TextView
    .... 
      android:drawableLeft = "@drawable/myImage"
  />
 
5. Compile and run!




Related Articles
Resources:
http://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableLeft
http://developer.android.com/reference/android/R.attr.html#drawableLeft